Class VehicleTrafficBehavior
Extends TrafficBehaviour with vehicle-specific process dispatch (Car vs Pedestrian vs Stopline layers) and dynamically steers sensors toward the next waypoint so that detection stays aligned with the vehicle's intended path on curved roads.
public class VehicleTrafficBehavior : TrafficBehaviour
Inheritance
Inherited Members
- TrafficBehaviour.searchAreaSensor
- TrafficBehaviour.keepDistanceOtherCarsAreaSensors
- TrafficBehaviour.trafficObjectContactParameter
- TrafficBehaviour.stoplineContactParameter
- TrafficBehaviour.KeepDistanceSensors
- TrafficBehaviour.CanProcessTraffic
- TrafficBehaviour.Processes
- TrafficBehaviour.IsHijacked
- TrafficBehaviour.SetController(Object)
- TrafficBehaviour.Start()
- TrafficBehaviour.OnDestroy()
- TrafficBehaviour.DoUpdate()
- TrafficBehaviour.CheckCanAddedProcess(TrafficProcess)
- TrafficBehaviour.OnSearchAreaSensorDetected(Collider)
- TrafficBehaviour.OnKeepDistanceSensorDetected(Collider)
- TrafficBehaviour.TryGetProcess(GameObject, out TrafficProcess, out TrafficProcess.ProcessData, out TrafficBehaviour.ContactStruct)
Remarks
The base class drives sensors as fixed frustums. For vehicles following waypoint paths, a stationary sensor aimed at the car's current facing can miss objects around a bend. DoUpdate overrides the base to rotate the search and gap-keeping sensors to face the next WaypointProgressTracker target each frame, keeping detection predictive rather than reactive.
Gap-keeping sensor radius is also narrowed proportionally to the turn angle so that the lateral spread of the arc does not detect vehicles in adjacent lanes during sharp turns.
Methods
DoUpdate()
Advances all active processes by one tick and removes any that have completed.
public override void DoUpdate()
Remarks
Marked virtual and public so the BT (AIBrainComponent) can call
it explicitly when IsHijacked suppresses the Unity Update loop.
TryGetProcess(GameObject, out TrafficProcess, out ProcessData, out ContactStruct)
Maps otherObject to the correct TrafficProcess subclass
and populates its ProcessData, using the object's layer
to distinguish vehicles from pedestrians.
protected override bool TryGetProcess(GameObject otherObject, out TrafficProcess process, out TrafficProcess.ProcessData processData, out TrafficBehaviour.ContactStruct currentContactValueParameter)
Parameters
| Name | Type | Description |
|---|---|---|
otherObject | GameObject | The detected object. |
process | TrafficProcess | Receives the newly created process instance. |
processData | TrafficProcess.ProcessData | Receives the process initialisation data. |
currentContactValueParameter | TrafficBehaviour.ContactStruct | Receives the contact thresholds for this interaction. |
Returns
bool — true if a process was created; false if the object should be ignored.
Remarks
The base implementation differentiates on the "Mine" layer (pedestrians/player)
versus all other layers (vehicles). Subclasses override this to add vehicle-type-specific
logic (e.g., checking relative speed before spawning a braking process).