Open alice-i-cecile opened 2 months ago
If we consider that practically all game entities will have StateScoped
, this would introduce a fixed global cost to spawning entities (or at least the root entities of hierarchies). What is the perf comparison between an OnAdd
hook and e.g. a system that polls for Added
(not that I'm recommending to use such a system, but we have a number of those in the bevy
codebase)?
OnAdd hooks will be paid once on entity spawning, and only for those entities which have the state scoped component. Added filters will be paid every frame, scaling linearly with the number of matching entities.
I'd love to see real numbers though.
I don't believe that's the correct complementary behavior. The current behavior is "despawn on exit", so its complement would be "spawn on enter", which would be genuinely useful but is blocked on the better scenes work. As another example, "show on enter" + "hide on exit" is already possible.
From @benfrankel in #15072
Originally posted by @MiniaczQ in https://github.com/bevyengine/bevy/issues/15072#issuecomment-2336693883