Simulation of all kinds of vehicles

Hello there to all users of the Unity engine.

I want to create a simplified (to some degree) simulator of all kinds of transport vehicles and need your advice concerning the capabilities of the Unity engine. I am new to Unity and my question is quite general about many things at once, so, please, redirect me to a right direction.

  1. Does Unity engine provide built-in components or classes for implementing vehicles of different kinds ?

  2. I want to simulate following kinds of vehicles:

  • Road vehicles (automobiles, buses, trucks including semi-trailers);
  • Railroad vehicles (trains, trams);
  • Mixed type vehicles (trolleybuses);
  • Conveyors and tubular transport;
  • Water vehicles (ships);
  • Air vehicles (helicopters, airplanes).

Do I have to invent everything from scratch or there are some pre-made classes for these types of vehicles ?

  1. I do not need super realistic simulation. Aspects which I want to simulate are following:
  • Realistic size and scale of vehicles and roads;
  • Realistic acceleration and braking;
  • Rotating wheels, rotating train bogies, railroad wagons snapping to railroad;
  • Rotating trailers;
  • Vehicles use traffic light system.
  1. All the controls of the vehicles will be external, so I do not need to simulate internal views of vehicles. It will be something similar to Transport Tycoon game or OpenTTD.

  2. Camera in game will be similar to OpenTTD, fixed view camera, isometric image, perspective view is disabled. Does Unity support isometric rendering ?

  3. Roads will be similar to OpenTTD, only square angle turns.

Railroads will have some smooth curves but they will be placed on the grid with automatic snapping to grid. I want railroads to be an array of “corner” points with fixed curvature, all the tracks will be either straight or have a predefined curve radius, to make things easy and run with high FPS.

All the game objects will also be snapped to the grid, similar to OpenTTD.

Is there a grid component with snapping in Unity ?

P. S.

  1. I have found a WheelCollider class for vehicles. It provides too much functionality for my project. I only need to move vehicles along the predefined path, rotate wheels and trailers and/or wagons. Is there a simplified class specific for my purpose ?

Thank you for your help.

Grid and snapping??? Use progrids =}

Spliness and unity joints

Thank you for directing me to splines. It looks like splines are a new feature in Unity engine. I did not see them several years ago when I tried to study Unity. Can you tell the best ways of creating roads with splines ? Maybe, some tutorials about spline roads. I mean the generic roads of all kinds – roads for road vehicles, railroads for trains, rollercoasters, tubes and pipes, conveyors and so on.

I have found a separate Spline Mesher tool, but it looks like this is a third-party add-on for the editor. I want to use the free version of the editor as much as I can. Is this functionality included into the standard Unity editor ? I want to create railroads either with several clicks in editor or programmatically by the runtime code. Thank you.

P. S.

I have tried a simple tutorial for splines.
I created a spline and added a “Spline Instantiate” component.
When I add my object into an array of objects to instantiate, I see the following error:

NullReferenceException: Object reference not set to an instance of an object
SplineInstantiateGizmoDrawer.DrawSplineInstantiateGizmos (UnityEngine.Splines.SplineInstantiate scr, UnityEditor.GizmoType gizmoType) (at ./Library/PackageCache/com.unity.splines/Editor/Components/SplineInstantiateEditor.cs:16)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Splines.SplineInstantiate.SpawnPrefab (System.Int32 index) (at ./Library/PackageCache/com.unity.splines/Runtime/SplineInstantiate.cs:1052)
UnityEngine.Splines.SplineInstantiate.UpdateInstances () (at ./Library/PackageCache/com.unity.splines/Runtime/SplineInstantiate.cs:850)
UnityEngine.Splines.SplineInstantiate.Update () (at ./Library/PackageCache/com.unity.splines/Runtime/SplineInstantiate.cs:768)

I see the sample sleeper object in the world, so it exists for sure.
What does this error mean ?

The screenshot:

1 Like

Yeahh i dont know a shit about coding,

You can use spline extrude component( add it to spline gameobject to form a basic mesh), maybe scale it down in one axis before placing a points for spline. If you just want some road, i guess you can use easyroads. Usefull asset

Thank you for trying to help me.

It looks like this is a bug of the editor. I have reported it via the built-in bug reporting tool. Ticket number is CASE IN-90058. I hope, developers will solve this, because Unity engine looks more interesting than Unreal Engine to me and I hope it will become better if developers fix all the bugs.

Since no one responded to me in e-mail and every one is having rest during the week end, I have tried to do what I can. It looks like something is wrong in the “PrefabUtility.InstantiatePrefab” method. It returns Null object which later raises an exception.

Here are the screenshots.

State before call.

State after call. Notice the Null object in the array.

For some reason the code does not check the result for Null object and this raises an exception.
I hope you guys know what to do with all this stuff because I am unable to jump into that function and see what it does. It looks like this function is taken from the compiled DLL or something which is not debuggable. Thank you.

Developers have closed my bug report without solving it.
Goodbye Unity.