ActionManager.OnPickTrigger doesn't work

This code is a part of my Booth class to create some board mesh with registered action.
First of all, OnPointerOver and Down works well, but only PickTrigger doesn’t work on board mesh.
To figure out the problem, i tried below solutions , but it didn’t work

  • board.isPickable = true
  • attachControl to my camera
    But it seems that ‘PickTrigger’ event just don’t work for every meshes.
public CreateBoardMesh() {
    for (let i = 0; i < 3; i++) {
      const board = MeshBuilder.CreateBox(
        `board-${i}-image`,
        {
          width: 2,
          height: 3.8,
          depth: 0.1,
        },
        this.scene
      );
      board.isPickable = true;
      board.parent = this.rootMesh;
      board.rotation.y = Math.PI / 2;
      board.position.set(3.6, 3, 0.715 + i * -2.5);
      board.edgesColor = new Color4(1, 1, 0, 0.7);
      board.edgesWidth = 5;

      const mat = new StandardMaterial("board-mat", this.scene);

      mat.diffuseColor = new Color3(1, 1, 1);
      mat.roughness = 0.5;
      mat.diffuseTexture = this.dummyTextures[Math.floor(Math.random() * 8)];
      board.material = mat;

      board.actionManager = new ActionManager(this.scene);
      board.actionManager.registerAction(
        new ExecuteCodeAction(ActionManager.OnPickUpTrigger, () => {
          alert("player clicked");
        })
      );
      board.actionManager.registerAction(
        new ExecuteCodeAction(ActionManager.OnPointerOverTrigger, () => {
          board.enableEdgesRendering();
        })
      );
      board.actionManager.registerAction(
        new ExecuteCodeAction(ActionManager.OnPointerOutTrigger, () => {
          board.disableEdgesRendering();
        })
      );
    }
  }

Sprites Examples | Babylon.js Playground (babylonjs.com)
I tried it out on playground, and OnPickUpTrigger worked
Simply cut two lines of code:
“board.parent = this.rootMesh;”
“mat.diffuseTexture = this.dummyTextures[Math.floor(Math.random() * 8)];”
In addition, if you want to listen to user click behavior, it is recommended to use OnPickTrigger.
However, I found that OnPickTrigger does not trigger when the mouse is blocked by another grid.

2 Likes

Thanks a lot!!!
I figured what the problem was based on your solution.
As you mentioned, my board mesh was being blocked by some of invisible collision meshes.