Skip to main content

Class AntiCollisionOtherCarsProcess

Reactive gap-keeping process that halts a vehicle whenever another vehicle enters its forward sensor arc within stopDistance, then clears itself once the leading car moves away.

[Serializable]
public class AntiCollisionOtherCarsProcess : TrafficProcess

Inheritance​

Inherited Members​

Remarks​

AI vehicles follow waypoint paths and may catch up to a slower car ahead (e.g., the participant's vehicle braking at an intersection). This process fires once the forward sensor reports a vehicle, pauses the invoker's movement command, and self-completes when the distance is no longer within range, at which point Completed resumes the invoker.

A hysteresis margin of 10 units is added to the stop-distance check after the first stop so that a vehicle hovering exactly at the threshold does not oscillate between stopped and moving on alternating frames.

The dot-product check (threshold 0.7) ensures the other car is genuinely ahead of this vehicle's forward axis and not merely nearby in a lateral or opposite lane — without it, a car waiting beside this vehicle at an intersection would trigger a false stop.

Methods​

Completed()​

Marks the process complete and resumes movement — called either when the leading car is no longer in the forward arc, or from ProcessData) if required parameters were missing.

public override void Completed()

GetProcessConstraint()​

Returns the concurrency constraint for this process type.

public override TrafficProcess.ProcessConstraint GetProcessConstraint()

Returns​

TrafficProcess.ProcessConstraint — The constraint that TrafficProcess) enforces to prevent duplicate processes from stacking.

Initialize(ProcessData)​

Applies processData configuration and resets IsCompleted so the process begins fresh.

public override void Initialize(TrafficProcess.ProcessData processData)

Parameters​

NameTypeDescription
processDataTrafficProcess.ProcessDataParameter bag populated by Collider).

Remarks​

Subclasses should call base.Initialize to clear IsCompleted, then read their keys from objectParameter and valueParameter.

Update(float)​

Advances the process by one tick; called each frame by DoUpdate until IsCompleted is set.

public override void Update(float deltaTime)

Parameters​

NameTypeDescription
deltaTimefloatElapsed time since the last frame, in seconds.
  • Remarks
  • Methods
    • Completed()
    • GetProcessConstraint()
    • Initialize(ProcessData)
    • Update(float)