Traffic Light

Youtube tutorial.

How To Customize City Crossroads

  1. Open Global Light Settings.

    Spirit604/CityEditor/Window/Global Traffic Light Settings

    _images/GlobalLightConnectionSettingsOpen.png
  2. Enable Show world info.

    _images/GlobalLightViewExample1.png
  3. You can now quickly view and adjust the timelines of all the crossroads.

  4. Enable Show disabled Lights to see crossroads with traffic lights switched off.

    _images/GlobalLightViewExample2.png
  5. Select the desired crossroad and press Select.

  6. In the TrafficLightCrossroad component, you can now set the timings.

How To Assign Light

  1. Open Global Light Settings.

  2. Enable Show light connections.

    _images/GlobalLightConnectionSettings.png
  3. Select Light connection type for example Traffic node.

    _images/GlobalLightViewTrafficNodeConnection.png
  4. Select H0 or H1 depending on the desired light index.

  5. Next, select the desired T (TrafficNode).

  6. Now, the selected TrafficNode will have the selected TrafficLightHandler.

  7. In the same way, you can assign PedestrianNodes and Light objects by changing the Light connection type.

    _images/GlobalLightViewPedestrianConnection.png

    Pedestrian node connection example.

    _images/GlobalLightViewLightConnection2.png

    Light object connection example.

Global Lights Settings

Window for quick display of crossroad timings and for linking the traffic lights to different entities.

How To Use

Read more here.

Settings

_images/GlobalLightSettings.png

Common Settings

Focus on select : move the SceneView camera to the selected traffic light crossroad when you select.
Show world info : show enabled traffic light data in the scene (example).
Show disabled lights : show all traffic light data (include disabled) in the scene (example).
_images/GlobalLightViewExample1.png

Scene light info example.

_images/GlobalLightViewExample2.png

Scene light info (include disabled) example.

Connection Settings

_images/GlobalLightConnectionSettings.png
Show light connections : on/off light connections in the scene.
Auto unselect handler : auto unselect TrafficLightHandler when connecting TrafficLightHandler traffic lights to any object.
Allow override light index : allow index traffic light overrides in traffic light objects.
Reparent light : traffic light object will be a child of the connected crossroad.
Light connection type :
  • All : show all connection types.

  • Traffic node : show traffic node connection only.

  • Pedestrian node : show pedestrian node connection only.

  • Light : show light object connection only.

Show connection buttons : show connection buttons for selected Light connection type.
Lights index : objects with a selected light index are displayed (-1 value - all indexes are displayed).
_images/GlobalLightViewTrafficNodeConnection2.png

Selected Light connection type : [TrafficNode] and Lights index : [0] example.

World Lights

Custom settings : on/off custom timeline settings for selected crossroad.
Timeline: shows light states of crossroad and total duration.

SceneView Light Objects Description

Select:
Unselect:
_images/GlobalLightAllConnections.png

All connection types and -1 light index are enabled example.

How To Replace Global Light States

  1. Open Global Light Settings window.

  2. Click the * button to expand the Replace settings.

    _images/replaceShared0.png
  3. Select the source state container you wish to replace.

    _images/replaceShared1.png
  4. Select your new desired State container.

    _images/replaceShared2.png
  5. Click the Replace button.

  6. As a result, all the source State containers are replaced.

    _images/replaceShared3.png

Shared Light State Container

Contains common timings of light states that are shared between traffic light crossroads. You can easily replace shared containers using the Global Light Settings tool.

How To Create

from the project context :

_images/sharedLightStatesPath.png

Default Container Path

_images/sharedLightStatesProjectPath.png

Project path example.

Settings

_images/sharedLightStates.png

Example.

Light States

  • Green : car only drives on a green lights.

  • Red

  • Yellow

  • Red Yellow : red and yellow lights at the same time, shown as orange in the inspector.

Light Index

Unique traffic light ID in TrafficLightCrossroad defined in TrafficLightHandler used to link TrafficLightHandlers and traffic lights by index.

Traffic Light Handler

Traffic Light Handler is an entity for handling the state of a traffic light. Is part of TrafficLightCrossroad.

Settings

_images/TrafficLightHandler.png
Traffic light crossroad : reference to the TrafficLightCrossroad.
Triggers : nodes that relate to the handler.
Traffic light parent : parent to which the light objects will be added.
Pedestrian light parent : parent to which the light objects will be added.
Related light index : linked traffic light traffic index.
Child lights : list of attached child light objects.
Custom lights : list of attached custom light objects.
Light states : light state of handler.

Components

Authoring

Traffic Light Object

Main Component

Traffic light object in the scene.

Contains data on the light frames and linked light indexes.

_images/TrafficLightObjectComponents.png _images/TrafficLightObjectExample.png

Traffic light object example.

Light Frame

Contains data on traffic light indicators.

_images/TrafficLightObjectFrameAssignExample.png
Traffic light object : reference to light frames.
Red light : red light state entity.
Yellow light : yellow light state entity.
Green light : green light state entity.
Initial light index : initial light index.
Index direction : direction in which the light index is displayed in the scene.