Version: 1.0.1
Language : English
Unity Hub
Adding modules to the Unity Editor

Turning Around Bends

  1. Before you start on this section, make sure that you have completed the previous section, Straight Line Movement.

  2. Create an Empty GameObject

  3. Drag it to the corner which the turn is at, and name it something distinct such as “Turn1”

  4. Go to the AIController Prefab located in Assets > Vehicle Simulation > CarparkDriving. In the Inspector window, click Add Component, and add AIMOrbit

  5. Click on the Running Man icon, and fill in the following accordingly:

    • Name or Label: Distinct Label describing this behaviour
    • Plane: XZ Plane
    • Radius: Start off with 10, we will finetune accordingly later
    • Delta Angle: Also start with -6, we will finetune later accordingly (positive value when turning clockwise, negative value when counter-clockwise)

  6. Then, add the this Decision Point to the Spawn Point as an AIMOrbit object

  7. Also, add this label to the Animator as an allowed behaviour

  8. We also have to take into account the straight road that the vehicle will travel along after it has completed the turn. Hence, follow the exact same steps again to create the next AIMFollow behaviour

    • Create GameObject and place it at the end of the straight road, name it
    • Add Component “AIMFollow” in AIController and name it
    • Add the subsequent Decision Point in the Spawn Point
    • Add the label as an allowed behaviour in the Animator

  9. At this point, you should have the following:

    • Animator with 3 different states, each state having an allowed behaviour
    • AIController module with 2 AIMFollow and 1 AIMOrbit components
    • SpawnPoint with 3 Decision Points
  10. However, there needs to have a trigger to allow the state to transit from one to another. Hence, we need to create these triggers.

  11. Right click on the Hierarchy and create a new Cube 3D Object.

  12. Drag it to the spot right before the turn is executed, and name it something you know. In addition, disable the mesh renderer as well as check the Is Trigger box.

  13. Now, add the component “Trigger State Transition”

  14. Since this is to change the state from 0 (Normal Driving) to 1 (Turning), the values will be the following:

  15. Change: 1 (final state value)
  16. Probability: 1 (any number between 0-1 to determine if the vehicle will turn or not)
  17. Is Braking Zone: Checked (to allow for deceleration before turning)
  18. Repeat steps 14-16, but this time drag the GameObject to the end of the turn. The values will be the following:

    • Change: 2 (final state value)
    • Probability: 1 (to complete the turn)
  19. Finally, you have a complete turn. Remember to fine tune the turning in step 6 by adjusting the parameters, or shifting the trigger created in steps 12-17.


  • New Updates Here
Unity Hub
Adding modules to the Unity Editor