How to make a single touch event on mobile? Help!

Hi everyone! I am stuck with a problem that Im sure is easy but I tried already like 40 different combinations of logic blocks and it still doesnt work. :confused:
So, here is the isuue - my goal is to make the arrow rotate 40 degrees everytime i touch block on a mobile device (Android).
However if i choose “Cursor\Touch on an object ‘Block’” in conditions and then “Do +40 angle ‘Arrow’” in events it starts to rotate infinitely after touch.
If I add “Once trigger” from Special finctions to conditions - as a result it rotates once, and if I touch the block again it wont react ( so I have to touch somewhere on the screen, and only after that touching block will react again, but again only once". I started to do some strange things with variables and timers but it didnt end up good. :frowning:

So I`m asking you for help, cos this engine is wonderful and it would be bad to give it up because of such a minor but still very important feature. :exclamation:

P.S. For PC mouse controller everything works fine when I put “On mouse release” and “Cursor\Touch over an object” conditions together, but I cant use it on Android device. It would be great if there was such a 'release touch' condition. Pity, but such function is only for multitouch tab, which I dobnt use.

Would be nice if someone sent me a screenshot of events logick for my case ( which is just for the test of this single touch function, I want to make an escape the room pointnclick game and I almost made all the logic for it :nerd: )

You need to think this a bit further.
So you tell to GD what to do when a touch happening on the block but what to do in case no touch happening? :slight_smile:

Try this:
event.png
Simply check if there is no touch happening on the block then, set the angle of the arrow equal to it current angle (whatever it is) and make sure you trigger this only once, otherwise the event going to be triggered every single frame until a touch happening but you don’t want that.

In case you want to rotate the arrow only a single time by 40 degree on each touch, just simply ‘Trigger Once’ the first event too:
event2.png
To check the opposite of a condition, you can invert the condition by checking the invert condition box on the bottom:
invert.png

Unfortunately, it didn`t work. However, thank you very much for giving your help. But, at 1st example it still rotates constantly until i touch somewhere not on the block. In 2nd example, it rotates once, but to rotate it again i have firstly to touch somewhere outside the block and only after that touch again on block. Which make no sense in gameplay - becuse player needs to press on button several times, not “press once on button, then somwhere on the screen, then again on button and do it 7 times”.(( :frowning: I want to press only on this button and make it react every time with single rotation of the Arrow object :frowning:

I haven’t tested on an actual android device but only in HTML5 and it works for me.
If it doesn’t works for you then maybe there is a conflict with other events in your scene.
Create a new empty scene, add nothing but a block and an arrow to the scene and create the events exactly as I showed you on the screenshots.

The trick in HTML5 testing in browser is that to rotate arrow I have to move cursor on block, then move it away and hover it above block again, which is exactly what i said is “touch block, touch somwhere else, touch block again”. On android device there is no constant cursor position tracking, so I need to touch outside of the bloc area to make it usable again. :cry:

Actually, on Android device the problem could be that it waiting for an actual touch to happen somewhere different than the block when it testing if touch is not on the block.

Instead , try to check if touch is NOT held by inverting the condition. It may works:
event3.png

Since there is no ‘Touch Released’ condition in GDevelop, this is the only thing I can suggest. Maybe you can also try the ‘mouse button released’ but I don’t know if it works with touch.

Ok, my previous suggestion is not going to work neither because the position of the touch/mouse still need to be changed for the first event to be triggered again…
I think I have just found the solution though:

Try this:
event4.png

I haven’t tested on Android, but I believe it should work.
If touch is down and the touch is on the block, it should rotate the arrow by 40 degree only once, to trigger the action again, you need to release the touch and touch the block again.

Yeah! It started reacting almost as it should. It really reacts to every touch now. Thank you for that! :slight_smile: However I wrote Do +90 angle, and in conditions it has “Once rtigger”+“Cursor\Touch over an object”+“Mouse button released” and in the game it rotates it twice ( 2*90 = 180 degrees). Which is strange and I will need to think how to adjust that.
But already thank you for yout help. Solving one problem leads to another :nerd:

I believe if you are using the Mouse Released condition, the Trigger Once condition is not required since the mouse is considered to be ‘released’ only for the next frame, the frame after that it should be considered as “not pressed or pressed” and the events should be not triggered anyway if you don’t press the mouse again and release it.

So try to use it without the ‘Trigger Once’ condition.

If doesn’t help, the next thing I can think of is that the ‘Trigger Once’ condition need to be on the bottom, the last event in your event block. I believe this is just the way it need to be.
So make sure the ‘Trigger Once’ condition is the last condition in the block as you can see in my screenshots.

Yeah!))) Thanx for your help! I cannot send a screenshot coz everything is in russian, but I found a solution:
First event is : “On scene start” > “assign Arrow.angle to var1”
Second Event: “Cursor\touch on Block” and “Left mouse button released” > “Do +90 angle Arrow” and “Assign Arrow.angle to var2”
Third event: “var1+90<var2”(the case when rotation is 180 degrees) > “Do -90 angle Arrow” and “Assign Arrow.angle to var1”

:exclamation: :slight_smile:

However it reacts only on every second touch :laughing: :smiling_imp:

The worst thing is that through Intel XDK Preview tab testing wia cloud server on my device it works on every touch. But after I create a Build it starts to react only every second time. So, I guess the problem is in Intel XDK rather than GDevelop(( :frowning:

PROBLEM SOLVED! :smiley:
The trick was in INTEL XDK Preview - it runs game differently than the final build. So to make it work exactly as I wanted in final build it was necessary to use just this simle logic:
“Mouse button released”+“Cursor\Touch on ‘Block’” > “Do +90 angle to ‘Arrow’”
Which is Absolutely logical! :slight_smile: :nerd:
But the Intel XDK preview led me in the wrong direction of overcomplicating things :smiling_imp: