Skip to main content

Traffic Objects

Traffic objects are everything on the street besides the agents. Some shape how a scenario plays out, such as stop lines that make agents wait and walls that keep the participant in bounds. Others, such as props, parked vehicles, and background characters, make the scene look and feel like a real street.

You can browse the traffic objects provided by HRI-MobiSim below to learn more.

Traffic Light​

Prefab:
  • TrafficObj_TrafficLight

A signal you can switch between red, yellow, and green, or set flashing, during a scenario.

Traffic Light preview

Keep in mind: Traffic lights are only visual. Agents don't react to the signal, so if they should stop at the light, place a stop line there too.

Using the Ready-Made Light​

The quickest way to start is the TrafficObj_TrafficLight prefab in Assets > mobisim > Traffic > Prefab. It changes its signals by itself with a ready-made Timeline, Sample_TrafficLight_Timeline, and shows a countdown timer. Make a prefab variant of it to fit your scenario.

The sample Timeline, and ready-made Signal assets for each traffic signal, are in Assets > mobisim > Traffic > Timeline Signals.

Changing the Signal​

Each signal stack needs a TrafficSignalController on the same GameObject as its Mesh Renderer. The controller switches which light in the stack is lit. You can drive it in two ways:

  • From an Event Trigger, by calling one of its functions:
    • TrafficSignalController.SetRedSignal()
    • TrafficSignalController.SetAmberSignal(), which shows yellow
    • TrafficSignalController.SetGreenSignal()
    • TrafficSignalController.SetSignalOff()
    • TrafficSignalController.SetFlashing(bool)
  • From a Timeline, with a Traffic Signal Track bound to the controller.

To show a countdown on the light, add a NumericValueDisplay component to the same GameObject as the TrafficSignalController, and enable Indicate Time on the Traffic Signal clips.

Signal changes are recorded by data collection. The TrafficSignalController logs a timestamped message each time its signal or flashing state changes.

Building Your Own Layout​

The traffic light is made of four signal stacks and a pole:

Signal Stack 3Signal Stack 2Signal Stack 1Signal Stack SidePole

You can freely kitbash them into the layout your intersection needs:

Traffic Light Design ATraffic Light Design BTraffic Light Design C

Which light a stack shows, red, yellow, or green, and whether it flashes, is set by its material. To change it, make a Material Variant of the base traffic light material, and adjust its color and flashing settings.

Traffic Light Material Inspector