Skip to main content

Class AntiCollisionOtherObjectProcess

A TrafficProcess that halts a traffic actor when a non-vehicle obstacle (such as a pedestrian or a stationary mine) enters the actor's sensor arc.

[Serializable]
public class AntiCollisionOtherObjectProcess : TrafficProcess

Inheritance​

Inherited Members​

Remarks​

This process is the pedestrian/mine counterpart to AntiCollisionOtherCarsProcess. While that process targets the Car layer and resolves a rigidbody parent, this one operates on Pedestrian and Mine layer objects — generic obstacles that do not follow the car-specific hierarchy. Keeping them separate avoids null-reference errors when resolving the parent vehicle GameObject.

Movement is gated on the sensor's forward arc (Vector3)), not just distance, so obstacles beside or behind the actor do not cause unnecessary stops. A configurable stopDelayTimer debounces the sensor boundary: the actor remains halted briefly after the obstacle exits detection, preventing rapid stop/resume jitter when a pedestrian lingers near the edge of the sensor arc.

Methods​

Completed()​

Marks the process as finished and unconditionally restores the actor's movement command. Called when the obstacle clears the detection zone and the debounce timer expires.

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)​

Each tick, checks whether the obstacle is inside the actor's forward sensor arc and within stopDistance; holds the actor stationary while the condition is true, then lets stopDelayTimer count down before completing the process.

public override void Update(float deltaTime)

Parameters​

NameTypeDescription
deltaTimefloatElapsed time since the last frame, in seconds.

Remarks​

Detection uses Vector3) rather than a plain distance check so that obstacles beside or behind the actor are ignored — only forward-facing threats trigger a stop. The squared-distance comparison avoids a per-frame square-root call.

While the obstacle is detected, stopDelayTimer is continuously reset to stopDelayDuration, keeping the actor stopped. Once the obstacle leaves, the timer counts down; when it reaches zero the process self-completes and movement is restored.

  • Remarks
  • Methods
    • Completed()
    • GetProcessConstraint()
    • Initialize(ProcessData)
    • Update(float)