Car Prefab Creator

Youtube tutorial.

How To Use

  1. From the Unity toolbar, open Car Prefab Creator.

    Spirit604/CityEditor/Car Prefab Creator

    _images/CarPrefabCreatorToolbar.png
  2. Drag & drop source cars from scene or project to Prefabs field depends on Prefab Source Type parameter.

    _images/PrefabSettings.png
  3. Configure the Common settings for creating a car.

    _images/CommonSettings.png
  4. If the vehicle is the Simple vehicle type, enable Add wheel offset in the Common settings tab.

    _images/physicsShape.png

    Custom physics entity shape result example

    _images/physicsShape1.png

    Simple physics entity shape result example

  5. Configure the Save settings for creating a car.

    _images/SaveSettings.png
  6. Change the Template settings depending on the name of the car body (if it is a child) and the pattern of the names of the wheels.

  7. Click Scan button.

  8. Open Additional Settings tab, adjust common settings for all vehicles.

    _images/AdditionalSettings.png
  9. After, open Prefab Info tab, adjust unique settings for each vehicle.

    _images/PrefabInfo.png
  10. Once all the settings have been customised, click Create to create the prefabs.

Prefab Settings

_images/PrefabSettings.png
Prefab source type:
  • Scene
    • Targets prefab parent : prefabs will be taken from the selected root from the scene.

  • Project
    • Prefabs : selected prefabs from the project.

Car type:
  • Traffic : prefab car will be created for the traffic.

  • Player : prefab car will be created for the player.

Cache container : cache data of saved vehicles.
Vehicle data collection : reference to the collection of all vehicles.
Traffic car convert template : template which contains traffic prefab template.
Player car convert template : template which contains player prefab template.

Common Settings

_images/CommonSettings.png
Assign hull mesh: should find the hull of the car.
  • Parent is hull mesh : car root contains a car mesh.

Fit physics shape to mesh : physical shape will be resized to the mesh size.
Has wheels : should search for wheels on a template.
Has navmesh obstacle: does the car contain NavMeshObstacle component.
  • Move threshold

  • Carve stationary

  • Carve time to stationary

Add offset: offset of the vehicle hull along the Y axis.
  • Fix pivot : fixes the pivot point if the pivot point is in the centre of the mesh.

  • Add wheel offset : adds wheel offset size.

  • Local offset : custom offset value.

Save Settings

_images/SaveSettings.png
Save to exist preset:
  • Scene: add the created prefabs to an existing preset in the scene.

  • Selected: add the created prefabs to selected preset.

New preset settings:
  • Assign new preset to scene : preset will replace an existing preset on scene.

  • New preset path : project path where to create a new preset.

  • New preset name : new preset name.

Prefab save type:
  • Override source : selected prefabs will be replaced by new ones.

  • Create new if not exist : new prefabs will be created only if there are no previously created ones by the selected path.

  • Override target : previously created prefabs will be overwritten in case of a duplicate.

Prefab save path type:
  • Original prefab path : prefabs will be created in the directory where the selected prefabs are located.

  • Template prefab path : Prefabs will be created in the directory where the template is located.

  • Custom path : user’s path of creation.

New prefab template name : pattern of the name of the created prefab (for instance Car1 (source name) + “_new” (pattern) = Car1_new).
Collection edit type:
Material type:
  • Source : material is copied from the source prefab.

  • Custom atlas material : user’s custom atlas material.

  • New unique material : new material is generated based on the user’s own material.

Template Settings

_images/TemplateSettings.png
Hull name templates : keyword phrases for automatic hull searches.
Wheel name templateskeyword phrases for automatic wheels searches.
  • Wheel FR : forward right wheel.

  • Wheel FL : forward left wheel.

  • Wheel BR : backward right wheel.

  • Wheel BL : backward left wheel.

  • Wheel Middle : additional wheels.

Preview Settings

_images/PreviewSettings.png
Show preview : on/off preview image of the prefab on the Prefab Info tab.
Show additional settings : on/off display of the additional settings of the prefab on the Prefab Info tab.
Show custom settings : on/off display of the custom settings of the prefab on the Prefab Info tab.

Additional Settings

Common Settings

_images/AdditionalSettings.png
Wheel radius : wheel radius.
Wheel offset : wheel offset by Y-axis of the vehicle.
Suspension length : suspension length of the vehicle. [Custom physics vehicles only]

Note

  • Editing additional parameters will affect all cars in the Prefab Info tab, to make unique parameters check the toolbox opposite on the parameter in the Prefab Info.

  • Arrow-button applies the setting for the selected parameter.

Physics

_images/AdditionalSettings2-1.png
Size offset : size offset of physics shape.
Center offset : center offset of physics shape.
Center of mass : center of mass of the vehicle.
Bevel radius : bevel radius of physics shape.
Mass : mass of the vehicle.

Info Tab

_images/AdditionalSettings2-2.png

Graphics

_images/AdditionalSettings3-1.png
Wheel source type:
  • Model unique : the wheels remain as in the original model.

  • Shared from model : the wheel model selected by the user from the original model is used for all wheels.

  • Shared all : the wheel model selected by the user shared between all wheels.

Wheel rotation type [shared wheel only]:
  • Source : the wheel rotation remains unchanged.

  • Flip left row : rotate the wheel in the left-hand row by 180° if you are using the wheel model from the right-hand row.

  • Flip right row : rotate the wheel in the right-hand row by 180° if you are using the wheel model from the left-hand row.

Has lods: on/off LODs for vehicle.
  • Lod 0, 1, 2 screen size : screen size of LOD.

Note

Wheel sharing is useful for using the same wheel model for all wheels to reduce drawcalls.

Info Tab

_images/AdditionalSettings3-2.png

Prefab Info

_images/PrefabInfo.png

Car Info

  • Prefab : reference to source prefab.

  • Name : user’s name of the vehicle.

  • ID : new ID entry for vehicle collection.

  • Traffic group : traffic group of the vehicle.

  • Override entity typenew entity type for selected vehicle (might be useful for specific vehicles such as tram).
    • Entity type

  • Public transporton/off public transport feature. (Settings)
    • Predefined road

    • Capacity

    • Entries

  • Settings type:
    • New : user-defined settings.

    • Template : vehicle settings are copied from the selected template [custom physics vehicle only].

    • Clone model : vehicle settings are copied from the selected CarModel in the list.

  • Wheel radius : wheel radius. (can be unique value)

  • Wheel offset : wheel offset by Y-axis of the vehicle. (can be unique value)

  • Suspension length : suspension length of the vehicle. (can be unique value) [Custom physics vehicles only]

Buttons

_images/Buttons.png
Scan : scan the added prefabs and add information about new ones to the Prefab Info tab.
Create : create new entity prefabs based on the added prefabs.