Mixing onPointerObservable with ActionManager not working

I dug into this quite a bit more and learned some things from the honorable @Deltakosh.

@bghgary is completely right about this. The sprite’s don’t exist in the depth buffer, so that means the pick operation doesn’t understand z-order. Priority is always given to a mesh when multiple things are picked, so the sprite is never actually “picked” in your original method…so the executeCode action never fires. The pick keeps thinking that a mesh is being selected, not the sprite.

So you then need to do a check to see if a sprite was hit first, and then act accordingly. So the method I used in the playground above is probably the best way to go about doing what you’re hoping to do.

Here’s a slightly simplified version with the action manager code stripped out.

https://www.babylonjs-playground.com/#XBPQ23#6

Hope this helps! Thanks for the fun investigative journey!

3 Likes