-
-
Notifications
You must be signed in to change notification settings - Fork 24
Class: RoadLane
RoadLanes are light extension of the 3D Path node, giving them a directionality and references to sibling lanes. These may be used for AI lane-following or navigation logic.
The above is to illustrate a manually defined RoadLane, typically these are auto generated and not directly visible in the editor:
RoadLanes are not created by default, but easily turned on.
- Select your RoadContainer object
- Enable "Generate Ai Lane"
- Optionally: Toggle on "Draw Lanes in Editor" or "Draw Lanes In game", which are both useful debug tools
There are cases where you might want to manually add a RoadLane. You can add it like any typical node and use built in Godot curve editor tools to place it as needed.
Once in your scene, much like at the RoadContainer level, you can choose to enable the debug options to view in the editor or game. This will then start drawing the sawtooth visual which indicates which way the lane is going.
- reverse_direction (bool): Reverse the intended flow of traffic. AI agents will need to consider this property when deciding which way is "forward" for the lane.
- lane_left (NodePath): If any, what is the RoadLane to the left of this lane (e.g. a faster lane)
- lane_right (NodePath): If any, what is the RoadLane to the right of this lane (e.g. a slower lane)
-
lane_next (NodePath): When a car gets to the end of this road (taking into account the
reverse_direction
state), what is the next RoadLane to start tracking. -
lane_prior (NodePath): If a car reverses down a road (taking into account the
reverse_direction
state), what is the prior RoadLane to start tracking. - draw_in_game (bool): Visualize sawtooth in the game. Warning: may cause slow rendering.
- draw_in_editor (bool): Visualize sawtooth in the editor. Warning: may cause slow rendering.
- lane_prior_tag (string): If this RoadLane is a child of a RoadSegment with a reference to a prior RoadPoint, use this tag name to attempt to auto-connect this RoadLane to the corresponding same-named tag of the prior RoadSegment
- lane_next_tag (string): If this RoadLane is a child of a RoadSegment with a reference to a prior RoadPoint, use this tag name to attempt to auto-connect this RoadLane to the corresponding same-named tag of the prior RoadSegment
- auto_free_vehicles (bool): Auto queue-free any vehicles registered to this lane it exits the scene.
When RoadLanes are generated, the addon will try to auto connect them to next and prior RoadLanes. This is done by matching "tag names" of the corresponding lanes. The addon employs its own convention for how lanes are named, and hence any lanes generated by the addon will auto connect. If you are simply using auto generated roads, you need not worry about this property at all.
If you are defining your own custom prefab scenes where you've manually created and placed your own RoadLanes, you could follow the same tagging convention that the addon uses to get the benefit of auto connecting your hand placed lanes to the auto generated ones by procedural segments. This means that the prior/next RoadLane NodePaths would be automatically set, which helps AI agents continuously follow your roads.
The easiest way to see what valid tags you should use is to make a single road segment which has the same configuration of lanes (number of forward and backwards), and then inspect the auto assigned tag names.
In the example below:
- lane_next_tag = "R3", this means this is the third reverse lane from the center. R0 would be a "fast" or inner lane.
- If this were a forward lane, it would be F3 instead (which again, would be a lane on the outside edge).
- lane_prior_tag = "R0a", this means this was a transition lane where the prior road point has fewer lanes that the next one. Thus, the beginning of this lane has to connect to a further inner lane. We tag this as R0a to indicate the start of this lane should match the position of the R0 lane, but we add "a" so that the name is distinct and won't get picked up by the prior RoadPoint and accidentally mark this added lane as the default "next" lane.
- If this were a scenario where a lane was being removed instead of added, then the append text would be R0r instead.
Notice how the generated node names for the RoadLanes in the above screenshot are actually defined after the tag names (p for prior followed by n for next). This is just for convenience, and since siblings must be unique, is not a naming convention you can fully rely on. But, this can make it quick to note down which tag names you need to apply in order for your own custom-added RoadLanes.
Current support: Godot 3.5+ Godot 4 planned for v1.0 of this addon (details)