#How to attach systems to scenes when creating them

14 messages · Page 1 of 1 (latest)

floral rampart
#

In godot C++, while it's a precompiled language there is a "register" feature. which lets you call registered methods by their name. This means that you can store a function's reference in a scene.
But i can't find this for bevy

shy turret
#

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?

floral rampart
floral rampart
uncut marten
#

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

hardy patrol
#

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)

GitHub

Observers is a super cool new feature, but I think there might be some gaps currently in the documentation around them, especially w.r.t when to use observers vs events. A quick list of things to m...

uncut marten
#

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.

hardy patrol
#

that's a good point thank you