HI guys !
What can I do to move/translate/teleport the mouse cursor to the other side of the screen?
I want to create an infinite loop, when cursor arrives to the end of screen it would keep continuously moving reappearing in the other side, something like in blender editorā¦
Hereunder a bit of pseudo code (that does not work, of course):
if action.x > 1918 then
action.x = 3
elseif action.x < 3 then
action.x = 1918
end
The snippet of code above will not actually move the cursor. It will merely change the positional information about the cursor which you received from the system. If you want to physically move the mouse cursor you can do so using DefOS:
defos.set_cursor_pos(x, y) -- In screen coordinates
defos.set_cursor_pos_view(x, y) -- In game view coordinates
@britzl In fact I donāt need the cursor to be visible, I need only that the positional information keeps running as I keep moving the mouse, but it stops when the cursor reaches the border of the screen/window.
Is there any other way of doing it? I mean, to keep compatibility with HTML5.
Thanks a lot!
Usually, one locks the hardware cursor in the middle of the screen, and hides it.
That way it will always produce delta values.
DefOS should be able to help with this.
Youāll then use āaction.dxā and āaction.dyā to in your scripts.
I believe getting the mouse position when āhoveringā is limited to the canvas size of the app.
Going full-screen would work, but that may not be possible. I seem to remember the mouse coordinates are still available when dragging (whilst keeping the mouse button down). If so, maybe that could help.
Yes, it is exactly what I want to doā¦
But if possible, not dragging, kind of like in Doom3 when we set the mouse to strafe/lookā¦
I am able to make the player complete two turns around himself only hovering, but I am trying to do a third person āflying shooterā and it would be nice if the loop would be infiniteā¦
Isnāt this exactly what defos.set_cursor_locked() does? Did you read the readme? A few people have done this recently with 3D projects on HTML5, you should take a look at Scene3D and Operator.
High Guys,
Iāve implemented the defold-pointer-lock,
and it works fine while the cursor is visible:
,but the input from keyboard is not detectable when the cursor is hidden.
Therefore the player does not move when the arrows ( throttle/breaks) are pressed, it just turns around himself with the mouse movement.
Do you have any clues?