#How to attach systems to scenes when creating them
14 messages · Page 1 of 1 (latest)
check out oneshot systems, though you may find that observers can provide this functionality more ergonomically. what's your use case, why do you want a scene-callable function?
it's absurd to not want a scene-callable function!
imagine if your scene has a timer that needs to trigger something from the scene collection.
also i don't think it's possible to serialize/deserialize a system.
it's technically not possible in a compiled language
What specific behavior are you trying to encapsulate? Something that runs when the scene loads? Or just when it is active?
ECS will have a different way of organising things compared to Godot for example
(in particular, scenes are just trees of entities and components in bevy. So they do not contain any systems, nor make any reference to any systems)
But there are plenty of tools for the behavior you could want, like observer to react to specific things, or putting systems in states, or whatever
Out of curiosity, how does an observer differ from an EventReader?
Ah this user points out observers only run when said even is Triggered. EventReader systems always run (even if basically doing nothing without events to read)
Both use independant streams of events, i.e. when you trigger an observer with event "MyEvent", it won't go into the EventReader buffer for that same "MyEvent" type.
and vice versa, writing to an EventWriter does not trigger related observers.
Second, they both provide different way to deal with events : EventReaders will allow you to read all events (possibly in parralel) at fixed points in the schedule, in a system. Observer, in contrast, will react to events being sent individually at the next command sync point, which is generally just after whatever sent the trigger is done.
that's a good point thank you