[Solved] Cursor misbehaves when touching draggable object and adding new touch

Is there a way to tell the cursor to stay on 1 touch? I like using the mouse events but I notice when I have a draggable object on the cursor, and randomly add another touch, the cursor jumps to the new touch and takes the draggable object with it. This could be wonderful if used wisely but might just annoy the person who keeps doing it on accident.
Thoughts??

Try to put in the conditions the expression - StartedTouchId () in brackets the number of the touch. For example, in the condition of comparing 2 numbers.

1 Like

Thanks I knew there had to be a way. I’ll try to figure this out tomorrow when I’m fresh, it’s really late now.

Ok I ended up not figuring out how to do this. So I will keep this issue open for now

Cursor events are exclusively designed for single touch.

As soon as you add multiple touches into the mix, it will switch to the newest touch, because it is a virtual cursor being moved around. You cannot ignore multitouch, so to accomplish what you’re looking for ,you will have to use multitouch events (but just use the first touchID).

You can look at the multitouch example to see how to move objects around based on multitouch, and just manually set it to the first touch ID (which I believe is 0)

1 Like

Ah ok see I was trying to set the cursor to the first multitouch event or to disable the cursor moving if more than one touch and enable it with just one touch. Which caused some weird screen jumps So i think what you’re saying is instead of using a cursor at all I should just rewrite all for multitouch? I was hoping to avoid this because I use some things, like the drag camera with mouse extension that don’t work without a cursor moving.
I’ll check out the example you’re taking about, the one I was looking at does not sound like that one it dealt with creating pointers.
Do you think it might be easier to make my own dtaggable behavior that ignores the cursor and just stays with the touch id that was originally on the object?

Sure, keep in mind the draggable behavior does some math to make it so the point you’re dragging stays the same as you move the object. Just using a change position behavior will make odd things happen (it’ll snap the object 0,0’s point to your touch)

I guess you could use the action “Deactivate moving the mouse cursor with touches” when the device is tactile.
https://wiki.gdevelop.io/gdevelop5/all-features/mouse-touch/reference

1 Like

Well I scoffed at your solution because I already tried it, but then I realized I hadn’t really tried it, I had just tried deactivating it under certain conditions and activating it under others, which caused weird screen jumps when it came back “on” and the touch was nowhere near the cursor.

So I tried what you said and it’s brilliant, it 100% solves the draggable teleporting issue.

Ok so if anyone can help with these two new issues:

  1. So how can I drag camera now with the mouse cursor deactivated. It is essential to my project that the user be able to drag around the environment, and with the mouse cursor gone I can’t use the extension I was using.

2)How can I call up a touch identifier and make sure it’s 0? Or whatever the first touch is, I’m actually having doubts it is 0 after some experiments I’ve been trying with the examples. I have a small sprite that I was using at the mouse position to help correctly identify which object was actually being chosen since touch/cursor just picks the whole square and not the collision mask. I used the sprite and the picking tools extension to get 100% accurate selection of object. So now I will need to create this sprite at a touch position instead of the mouse position but only if it is the first or only touch. Can anyone help me solve how to tell which one that is?

Actually on point 2 I might be able to check for point inside instead, but it’s still asking me to use the touch identifier and I’m not sure how to get that still. Trying with just 0 doesn’t work.
Actually I got that now, it is TouchX(StartedTouchId(0),“”,) etc. Although picking up draggables, without even moving them, now makes the edgescrolling go crazy. Sigh. Also it doesn’t work as the identifier for a touch ended. In the I guess old examples I’m looking at they’re just using a touch has ended with no identifier but I’m not seeing that option.

Where do I even begin.

Ok taking the example project and just adding a minor thing. First interesting thing, even if I change the condition of enabling the effect to use the Marker variable TouchId to be 0 (and I tried 1 too) it does not work at all. Even with just 1 touch on screen. So I’m not sure how you’re ever supposed to call forth what touchid a touch is using to make sure it is the touch you want.

Another interesting thing, even if the marker sprite is not in collision with the table anymore because you lifted your touch and the marker was deleted, the drag and effect remain enabled, and won’t disable until you touch the screen again and the touch is not on the table. Which is kind of a good thing because of the way activating a draggable object is like, “yep I’m active, but you would never be able to tell because you can’t actually drag me unless you let go of me and try again, muahaha”

Another interesting and actually workable though most likely unintentional thing is that even under the repeat event, if you have multiple touches/markers going they will never activate the effect unless you happen to put them all on the the table at once or have one on the table and lift the others off the screen. And if you have one touch on the table and add a touch anywhere else it immediately deactivates it which can be useful.

Sad news, 2 touches can activate a table each and I’m nowhere closer to finding out which touch is the first one and declaring it as the only one allowed to activate anything.

Just to update, after spending some time with the available multitouch resources I devised a way of keeping my cursor, my multitouch, my draggable objects and my cursor-dependent extensions all living in peace and harmony, without jumping screens or teleporting draggable objects.