Mobile Traffic System
  • Key Features
  • Demo App
  • Quick Start
  • Setup Guide
    • Prepare Scene
    • Vehicle Pool
    • Initializing Asset
    • Create a Road
    • Connect Roads
    • Priority Crossing
    • Priority Intersection
    • Traffic Lights Crossing
    • Traffic Lights Intersection
    • Setup Give-Way Waypoints
    • Roundabout Setup
    • Highway Enter Setup
    • Speed Routes Setup
    • Vehicle Routes Setup
    • Waypoint Priority Setup
    • Waypoint Setup Window
    • Waypoint Properties
    • Vehicle Implementation
    • Truck + Trailer Implementation
    • Path Finding Setup
    • Player Component
    • Change drive side
    • Debug Window
  • Complete API
    • AddDrivingAction
    • AddExcludedVehicle
    • AddExcludedVehicleToSystem
    • AddVehicle
    • AddVehicleControl
    • AddVehicleWithPath
    • AddWaypointEvent
    • ChangeLane
    • ClearPathForSpecialVehicles
    • ClearTrafficOnArea
    • DisableAreaWaypoints
    • DriveActions
    • EnableAllWaypoints
    • ExcludeVehicleFromSystem
    • GetAllVehicles
    • GetClosestWaypoint
    • GetExcludedVehicleIndex
    • GetExcludedVehicleList
    • GetPath
    • GetPriorityCrossingStopState
    • GetTrafficLightsCrossingState
    • GetVehicleComponent
    • GetVehicleIndex
    • GetVehicleSpeed
    • GetVehicleState
    • GetWaypointFromIndex
    • Initialize
    • InstantiateTrafficVehicle
    • IsInitialized
    • RemoveDrivingAction
    • RemoveVehicle
    • RemoveVehicleControl
    • RemoveVehiclePath
    • RemoveWaypointEvent
    • SetActiveSquares
    • SetCamera
    • SetCameras
    • SetDestination
    • SetEngineVolume
    • SetHazardLights
    • SetIntersectionRoadToGreen
    • SetPriorityCrossingStopState
    • SetTrafficLightsCrossingState
    • SetTrafficDensity
    • SetVehiclePath
    • StopVehicleDriving
    • TrafficOptions
    • TriggerColliderRemovedEvent
    • UpdateVehicleLights
  • Events
    • onDestinationReached
    • onVehicleAdded
    • onVehicleCrashed
    • onVehicleRemoved
    • onWaypointReached
  • Delegates
    • Building In Trigger
    • Dynamic Obstacle In Trigger
    • Modify Trigger Size
    • Player In Trigger
    • Spawn Waypoint Selector
    • Traffic Lights Behaviour
    • Vehicle Crash
  • External Tools
    • Easy Roads
    • CiDy
    • Road Constructor
  • Visual Scripting
  • FAQ
  • V2 vs V1
  • Upgrade Guide
    • Upgrade from v1.x.x to v2
    • Upgrade from v2.x.x to v2.3.x
  • Releases
  • Support
Powered by GitBook
On this page
  • Truck Implementation
  • Trailer Implementation
  • 1. Add the trailer attachment point.
  • 2. Add trailer prefab inside & attach TrailerComponent.cs to it
  • 3. Add the TrailerHolder
  • 4. Add the truck attachment point.
  • 5. Assign the trailer attachment point.
  • 6. Add trailer collider.
  • 7. Configure the wheel pivots
  • 8. Automatically configure
  • 9. Add the trailer component to the truck
  1. Setup Guide

Truck + Trailer Implementation

PreviousVehicle ImplementationNextPath Finding Setup

Last updated 1 year ago

Truck Implementation

The truck implementation is identical to the vehicle implementation. See Vehicle Implementation

Ensure that the truck functions correctly within your scene by testing it before proceeding to implement the trailer.

Trailer Implementation

The truck should look like this before starting to add the trailer:

Follow these steps to implement the trailer properly:

1. Add the trailer attachment point.

Create an empty GameObject and position it precisely on the attachment point. This represents the point where a joint will be created.

The trailer has a similar point and the 2 points should have the same position.

2. Add trailer prefab inside & attach TrailerComponent.cs to it

A Rigidbody will be automatically created for the trailer.

Ensure that the mass, drag, and angular drag values of the trailer match those of the truck for optimal performance.

It is not essential to position the trailer correctly inside the prefab initially, as it will be automatically placed in the correct position later on.

3. Add the TrailerHolder

Create an empty GameObject, position it as the first child, set its position to (0,0,0), and then place all other GameObjects from the trailer prefab inside it.

This is necessary to automatically position the center of mass and configure other internal settings.

4. Add the truck attachment point.

Create an empty GameObject and position it where you intend the trailer to connect to the truck. During runtime, the attachment points of the truck and the trailer will align, so it's important to ensure their positions are precisely set on top of each other. Pay close attention to their positions.

5. Assign the trailer attachment point.

Assign the anchor point to the TrailerComponent script.

6. Add trailer collider.

Add one or more colliders to the trailer, depending on its geometry.

7. Configure the wheel pivots

The wheels of the trailer should be configured as any vehicle wheels.

The first pivot should be on the ground as shown here:

The second pivot should be in the center of the wheel. The difference between the first pivot and the second pivot represents the wheel radius.

Inside the second pivot, you should place your wheel graphic with the pivot in the center of it.

8. Automatically configure

After all the above setup is done, press the Configure Trailer button.

If everything is successful the following message will appear inside the console:

This will automatically create a configurable joint and assign all the necessary references.

By default, standard settings will be applied. However, if you prefer custom settings, you can configure the joint from the trailer according to your preferences.

If something is not properly configured, you will get a message inside your console informing you that something went wrong.

9. Add the trailer component to the truck

On the VehicleComponent from the truck add the trailer and the Trailer connector:

Afterward, click the 'Configure Car' button, and the trailer should snap into the correct position. Additionally, the Rigidbody from the joint should be assigned.

Don't forget to set the Layer of the prefab and all its children to the Traffic Layer to work properly

Working truck