How do I set the right click to do a different action

For my game, I want to be able to use the right mouse click to do a certain move.

How do I disable the context menu and check for a right click?

Hello @SayHiToMePls ,

PlayCanvas has a very handy function for disabling context menu. You can find it here:

https://developer.playcanvas.com/api/pc.Mouse.html#disableContextMenu

For the detecting a right click you can take a look at this tutorial:

https://developer.playcanvas.com/en/tutorials/mouse-input/

Here is the code block for what you’re looking for:

Mouse.prototype.onMouseDown = function (event) {
  // If the right mouse button is pressed, change the cube color to blue
  if (event.button === pc.MOUSEBUTTON_RIGHT) {
      // do something
  }
}
4 Likes