pokepetter / ursina

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

Setting mouse.visible = False in borderless mode causes client window to snap back to original location #683

Closed jamesw732 closed 1 week ago

jamesw732 commented 2 weeks ago

This is best demonstrated by example. Run the following, drag the client window somewhere besides the original location, then right click inside the window.

from ursina import *
app = Ursina(borderless=False)

def input(key):
    if key == "right mouse down":
        mouse.visible = False
    elif key == "right mouse up":
        mouse.visible = True

app.run()

For context, I'm writing the beginnings of a 3rd person 3D game and I allow for the player to rotate the camera with their mouse while right clicking. Upon right clicking, I set mouse.visible = False and then for each frame while right click is held, compute the mouse's displacement and overwrite its location with the original mouse location. The displacement is then translated into camera rotation. When right click is released, I set mouse.visible = True.

A viable workaround is to keep the mouse visible and not overwrite the mouse location. I'm an amateur game dev, so I may have had the wrong approach in the first place or missed something simple, but this still seems like a legitimate bug. Feedback is appreciated :). Otherwise, I may take a stab at this eventually.

pokepetter commented 1 week ago

Thank you for the bug report. This has now been fixed.