Megafunk / MassSample

My understanding of Unreal Engine 5's experimental ECS plugin with a small sample project.
MIT License
682 stars 112 forks source link

Do All Processors Tick Excecute every frame by default? #16

Closed OptimisticMonkey closed 2 years ago

OptimisticMonkey commented 2 years ago

(First - thank you for creating this sample project - it is super helpful)

I noticed that the execute method is being run by most processors on every frame, even if nothing has been spawned. Is this the intention? The method is very fast - but seems like should be more of an opt in?

Megafunk commented 2 years ago

Yes, this is how most ECS libraries work. Processor ticking is the default! However, if the queries are empty they simply get passed over like you said.

Observers are the exception where they only execute when the action they observe occurs + the subsystem calls them.

I do agree that all systems executing even when you are certain a specific query will never be hit is a little bit weird. I think it might be possible to unregister processors from the dependency graph at runtime but I would not recommend doing it as the dependency graph takes a while to rebuild. I'll look into it later...

We will mention this in the docs somewhere to make it more clear soon!