Bevy_city traffic#23603
Conversation
| pub tree_large: Handle<Scene>, | ||
| pub path_stones_long: Handle<Scene>, | ||
| pub fence: Handle<Scene>, | ||
| #[cfg(feature = "traffic")] |
There was a problem hiding this comment.
My initial preference is to use a runtime toggle for this, not a feature flag. Make the case to me for why we should compile this out?
There was a problem hiding this comment.
i was mostly doing it for conveince. I can add it as toggle in settings instead
| license = "MIT OR Apache-2.0" | ||
|
|
||
| [features] | ||
| trace_tracy = ["bevy/trace_tracy"] |
There was a problem hiding this comment.
Why is adding this as a feature to our example in particular useful?
There was a problem hiding this comment.
was trying to get tracing to work . I'll get rid of that
| (TrafficLightColor::Green, TrafficLightPhase::Green) => &materials.green_on, | ||
| (TrafficLightColor::Green, _) => &materials.green_off, | ||
| }; | ||
| commands |
There was a problem hiding this comment.
This will be meaningfully slower than mutating the handle.
| "GREEN_LIGHT" => TrafficLightColor::Green, | ||
| _ => continue, | ||
| }; | ||
| commands.entity(descendant).insert(TrafficLightBulb { |
There was a problem hiding this comment.
Ditto here: don't use commands when you could just mutate.
| } | ||
| } | ||
|
|
||
| // Component/material for bulb |
There was a problem hiding this comment.
Comment is unclear (and it should be a doc comment).
5197d42 to
8799cca
Compare
|
I'm working on multiple changes that will heavily conflict with this. The traffic simulation I have planned is also pretty different to what you are doing here. I'm going to change how the hierarchy is spawned to make it much easier to work with and not make the cars children of roads. Also, in general, I prefer keeping PRs small and focused so I would suggest making a separate PR that only adds the traffic lights without any simulation. |
Objective
Solution
TrafficLightand associated enums for LightPhase and LightColor.TrafficLightMaterialsand .glb assetTrafficPluginCarfor handling traffic logicapply_traffic_rulesfor querying roads, cars and traffic light states.intersectionTesting
Right now it's feature gated and currently WIP.
Tests could be done for traffic logic, cars keeping distance at stop, possibly turning.
Showcase