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

Request: Cursor teleports to mouse position when clicking anywhere (super important for mobile games) #25

Closed Ragetto closed 1 year ago

Ragetto commented 2 years ago

https://forum.defold.com/t/rendercam-defold-input-weird-cursor-position-when-scrolling/69387/7 "This is something the cursor script should support. Please create a ticket in GitHub!" (Britzl)

This feature completion is definitely something anyone working on a mobile game would (absolutely) need :) . . .


Is your feature request related to a problem? Please describe (REQUIRED): Defold Input extension (by Britzl?) => Currently the cursor can't teleport where the user clicks, which is a huge problem for mobile games (since there is no draggable cursor on mobile, we need to move it instantly where the user taps the screen)

When passing the "mouse position" to the cursor from the "if pressed" input, nothing happens.


Describe the solution you'd like (REQUIRED): It should be possible to pass the "mouse position" message from the "if pressed" input (or any other solution).

So the cursor would instantly teleport to the object and would make the extension useful for mobile game developers.


Additional context (OPTIONAL): Here is the minimal version of my current project: https://github.com/Ragetto/20211002_-PUBLIC-_defold_input_cursor

britzl commented 2 years ago

I don't really understand the problem. The cursor will always position itself on each input event:

https://github.com/britzl/defold-input/blob/master/in/cursor.script#L28-L43

One problem that can happen since collisions are async is that when the cursor is moved on a touch event it will result in a press in the same frame but a collision in the next. This is handled in the cursor script by delaying the handling one frame:

https://github.com/britzl/defold-input/blob/master/in/cursor.script#L145-L152

If this still is a problem the only thing I can think of is to change from collision objects to ray casts as those can be resolved in the same frame.

britzl commented 1 year ago

Closing as no further info is provided.