Class AntiCollisionStoplineProcess
A TrafficProcess that models real-world intersection dwell behaviour: the traffic actor decelerates to a full stop at a designated stopline and waits for a configurable dwell time before being allowed to proceed.
[Serializable]
public class AntiCollisionStoplineProcess : TrafficProcess
Inheritance
Inherited Members
- TrafficProcess.EditorDislayName
- TrafficProcess.IsCompleted
- TrafficProcess.GetProcessConstraint()
- TrafficProcess.Initialize(TrafficProcess.ProcessData)
- TrafficProcess.Update(float)
- TrafficProcess.Completed()
Remarks
A dot-product heading check rejects stoplines that are not squarely in front of the actor, so vehicles that have already passed through, or are approaching from a perpendicular street, do not trigger a second stop.
A stoppedOnce flag prevents the dwell timer from resetting if the vehicle overshoots
the stopline slightly — without it, a small forward/backward oscillation would restart the
timer every frame and the vehicle would never proceed.
Methods
Completed()
Marks the process as finished and unconditionally restores the actor's movement command. Called when the dwell time has elapsed or the stopline is no longer relevant (actor has passed, or approach angle is wrong).
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
| Name | Type | Description |
|---|---|---|
processData | TrafficProcess.ProcessData | Parameter 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, evaluates the actor's bearing and proximity to the stopline and enforces the mandatory dwell time before allowing the actor to proceed through the intersection.
public override void Update(float deltaTime)
Parameters
| Name | Type | Description |
|---|---|---|
deltaTime | float | Elapsed time since the last frame, in seconds. |
Remarks
A dot-product check (< 0.7f) rejects the stopline when it is not squarely ahead of the actor. This prevents vehicles that have already cleared the line, or that are approaching from a side street at a steep angle, from triggering a spurious second stop.
The stoppedOnce flag ensures the dwell timer is started exactly once per approach.
After the dwell time elapses, movement is resumed. If the actor has stopped and is now
further from the stopline than stopDistance, the process completes immediately.