Mau125
Mau125

Reputation: 1

Change mouse position in p5(with pointer lock api)

I want to make the mouse go to the center of the screen every time it hits the border in p5 but i dont know how to change the mouse position, is there a way to do that with pointer lock api?

Upvotes: -1

Views: 290

Answers (1)

Kroepniek
Kroepniek

Reputation: 395

You could use the noCursor() function to hide the real cursor and keep track of your own cursor. Just make an object and change it's position based on the real mouse position changes and if the fake cursor hits the border, just set it's position to your desired new value.

https://p5js.org/reference/#/p5/noCursor

Upvotes: 0

Related Questions