[Solved] Virtual Controller with "A new touch has started"

Hi,

I used sprites of simple Left/Right arrows as virtual controller, and I used “Touch or Left mouse button is down” at the beginning, but the result was not “smooth”, sometimes it got stuck, like the character was not moving at all or the animation was not changed properly, if I pressed the button too quickly or something.

After some research, I found that you have to disable “Move mouse cursor when touching screen”, then all the buttons were not working…

So I had to change all the “Touch or Left mouse button is down” to " A new touch has started", turned out the result was good, smoother than the old ones, but my character seemed like he’s glued at the ground, the animation was working properly, he was running, but not move at all.

Can anyone help me? Thanks in advance~!


Are the button animations working, just not the player?

hi, thanks for your helping!

Yes, the animation works just fine, press the button, run, not press the button, not run. Only the player do not move at all.

The player doesn’t move, or the player’s animation doesn’t move?

hi,

the player don’t move, the player’s animation is just fine, just like running on the spot.

I try another way to “add a force”, then I find that the player can move a little if I repeatedly hit the controller key, just move a little each time, pretty weird.

In the multiplayer tutorial is an example with forces, in this case is for a movingPlatform, but it can be applied to the player

https://editor.gdevelop-app.com/?project=example://multiplayer-platformer-with-gamepads

1 Like

hi, thanks for you reply, I will give it a try. :smile:

“A new touch has started” works only once. Once it’s started, it’s not starting anymore, right?
So you trigger the walking animation, but the simulate key works only one frame (1/60th second).

This is explained in the condition:

2 Likes

Thank you so much for your explanation! That clarify my question! :wink::wink::wink:

Hi~ It turns out I don’t have to use " a new touch has started ", “the cursor/touch is on” can handle the control. :joy:

That will work fine until you add another button, jump, shoot, etc.
Then you will need multitouch

1 Like

Hi Gruk , I’ll keep that in mind, thank you for your reminder ! :kissing_heart: