How to check if the mouse is holding

when i press the button, it only works if i click, i doesn’t work when i hold, can someone please help me with holding the mouse or holding touch???

Ηι @jus.co_ding_me_23,

There isn’t a mouse hold event, there is a mouse down and a mouse up:

https://developer.playcanvas.com/en/api/pc.Mouse.html#event:mouseup

So after listening for the mouse down event, you can set a script property to true:

this.mouseButtonIsHolding = true;

And when the mouse up event fires, set it back to false. Now you know when the mouse button is “holding”.

There’s also this:

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

2 Likes