scene.onBeforeRenderObservable and Mask

Hi folks!
I’ve noticed that it is possible to add an observer with a specific mask. Now how can I tell the scene.onBeforeRenderObservable to only notify observers added with this specific mask?
Any help appreciated :slight_smile:

That would require the object notifying to send a mask as well. in the case of the scene, it is not providing any mask, so it won’t work as you expect it to. it will work in the case of scene.onPointerObservable, where you can pass the pointer event type (pointerdown, pointerup etc’) as a mask, and the observable will filter the observers accordingly.

1 Like

Ok, I see. What I’m trying to acheive is the following. I have a couple of Gameobjects which register themselveves to scene.onBeforeRenderObservable to execute various Gamelogic related stuff like AI-logic, updating position etc. Even GUI (sliding in of menus, Help/Credits…) register their update-logic as well. So i don’t have a central update function which itterates the GameObjects an calling their respective update functions.
At a certain point, say showing the Help-Screen, I want to halt all Gamelogic related observers so only the GUI related observers are still active. I think having the possibility to specify a mask for scene.onBeforeRenderObservable would come in handy.
Do you can think of alternative ways of how to implement such an behavior?
Thanks in advance :slight_smile:

You can maintaining your state and removing unneeded observers or filtering on your own remove the callback. The more efficient variant would be to remove them when they are not needed and as them when they should run

Ok, I think I’ve got the idea. Thanks for helping out

1 Like