subsoap/defos

FPS cursor lock

subsoap opened this issue · 2 comments

I'm unsure how to do a FPS cursor lock properly

set_cursor_locked at the middle of the view messes up with the dx,dy - it always returns to the original place when rotating

set_cursor_clipped does does not produce dx,dy values once the cursor reaches the edge of the view when the game is in window mode

defos.set_cursor_locked(true)
defos.set_cursor_clipped(true)

Looking at an older FPS project I worked on I looked at the actual cursor position and then manually moved it back to center every frame, so it's not possible to make it play nice with set_cursor_locked and builtin dx,dy?

https://github.com/subsoap/fps/blob/master/main/camera_helper.script

Yeah. defos.set_cursor_locked() doesn't even report dx dy on macOS. It's unusable in this state.

Maybe a PR to Defold to make it report the real dx dy even when the cursor didn't move or was programatically teleported would solve this.

The solution for now is to hide the cursor then move it to the center each frame.

I'll close this since #81 and #64 discuss the exact same issue