britzl / defold-input

Simplify input related operations such as gesture detection, input mapping and clicking/dragging game objects
MIT License
111 stars 26 forks source link

Cursor following the mouse - Position passed to cursor from update function => conflicts #26

Open Ragetto opened 2 years ago

Ragetto commented 2 years ago

From Defold forum https://forum.defold.com/t/rendercam-defold-input-weird-cursor-position-when-scrolling/69387/6


DEFOLD INPUT (cursor) (+ camera? not sure there is a link)

Real-time following... when not moving the mouse When passing the "follow position" message from the input function (as recommended by Britzl), the cursor doesn't follow the mouse when this mouse doesn't move (ex: after scrolling and move moving => the mouse keeps its screen position while the cursor follow the camera movement)

What I did do to make the cursor follow the mouse no matter what? I’ve added the message passing (to the cursor) in the update loop, which makes the cursor follow the mouse as intended... but it seems to have created some sort of “conflicts” with the other cursor’s action_ids...

Recap When passing the "follow position" message from the update loop, the “release” input is no longer detected after I have clicked the building. I have to move the mouse to "confirm" the release and upgrade the building.


Here is a minimal version of the project here: https://github.com/Ragetto/20211002_-PUBLIC-_defold_input_cursor

britzl commented 2 years ago

after scrolling and move moving => the mouse keeps its screen position while the cursor follow the camera movement

Yes, this happens since the cursor is based on the position of the cursor game object and it follows any camera offset.

The solution is:

I’ve added the message passing (to the cursor) in the update loop, which makes the cursor follow the mouse as intended

BUT apparently this causes a problem:

When passing the "follow position" message from the update loop, the “release” input is no longer detected

I believe the only proper solution is to move from a collision object to ray casts.