pokepetter / ursina

A game engine powered by python and panda3d.
https://pokepetter.github.io/ursina/
MIT License
2.23k stars 326 forks source link

How to solve glitch with mouse lock/unlock? #411

Open deangelisdf opened 2 years ago

deangelisdf commented 2 years ago

Hi all, i'm a new user for Ursina engine. I'm tring to use FirstPersonController and i want unlock mouse when i stay in pause menu. When i unlock the mouse cursor i don't see any issue, but in case to lock the screen is not refreshed properly because became black for a little amount of time.

mouse.locked = not(mouse.locked)

Do you know how to solve it or to avoid it?

Thanks to advance

C0rupted commented 2 years ago

I myself had the same issue, however, I had to use longer code for it to work:

if mouse.locked:
    mouse.locked = False
else:
    mouse.locked = True