ActionManager.OnPickTrigger not firing

Hello,

i am trying to use action manager to detect pick actions on my meshes. I am adding ActionManager.OnPickTrigger to my mesh, but the problem is that this action is not triggered when i click on a point that is hidden behind other mesh. Imagine a ground and multiple objects on the ground. I want to detect picking on ground even when i click on some other object.

Is there a way how to enable picking of meshes when the mesh is hidden behind other mesh?

Thank you.

Of course. Setting a predicate for the picking, or setting the rest of the meshes unpickable will get you the result you want.

The simplest example is this:

https://www.babylonjs-playground.com/#NU4F6Y#238

if you define the pointer down predicate to only return true to the wall mesh (in this case, wall. in yours, the ground), you will get the right picking point, ignore the box

scene.pointerDownPredicate = (mesh) => {
    return mesh === wall;
}

Yes, that works. However that requires some management what is currently pickable and what not. Some of my actions don’t care if the mesh associated with the action is behind some other pickable mesh. I suppose there is currently no other way how to receive both picks when using actions? Like in this playground.

You can trigger your own pick and set the predicate as you wish. The scene pick function (Picking Collisions - Babylon.js Documentation) has an optional that you can set whenever you want.

The action manager is a (very) nice wrapper around the scene functionality. The scene predicate will work on that as well.

If I understand you correctly, you want to enable pick on the box, but get the wall. Why can’t you simply set the box isPickable to false?

I wanted to trigger both actions - on the wall and on the box, wall doesn’t care that it is partially hidden. I understand that i can either set isPickable to some meshes or i can set the predicate on the scene but this is what i refer to as management which i wanted to avoid.
Maybe i am just complicating things. I made my ground pickable for now and all other meshes as unpickable and i’ll see if i hit some problem later.