Touch screen problem

So I coded the touch screen controls for my game which I release last week. It was only for keyboard at the time an I have decided to move it to mobile/touch screen. I have made the touch controls and placed them a good distance from each other. The problem I am having is that when the crouch function is enable the roll touch doesnt work and when the crouch is disabled the roll function work with the touch moving over to keyboard the touch controls totally disable the crouch on the keyboard. I want to know if I shout just move the touch buttons in the same events as the keyboard. because currently they are on a separate event list.

Thank for the help Guys

It’s hard to tell without seeing how you’ve structured your inputs. I would suggest you have 2 separate input routines - one for keyboard and one for touch. Only process the touch is there’s a touch screen (use image) , otherwise use the keyboard input events.

1 Like


Depending on what order you have them being executed. If the mouse/touch is on roll, it will also not be on crouch. So it’s very possible that the crouch events are getting actioned after the roll events and over-riding them.

I’d suggest you look at a finite state machine (or FSM), which keeps track of what state the player can be in (idle, run, jump, attack, crouch, roll etc). The for each state, add events that handle key presses or touches. So rather than a one-size-fits-all generic approach, have a more specific and targets movement events.

1 Like

Thank for the reply MrMen

Spent the entire night recoding my events for Boolean Variables and Number Variable states. I have made two different scenes to test this on and it is still doing the same thing even if the states are boolean or numbered. If I swap the orders around they also do the same actions by swoping around. IE if crouch is trigger first then roll is disabled. And of course this also disables the entire crouch system for the keyboard. What I do not understand is that all the other touch buttons work in the game but for some reason the crouch and roll are the only ones that are having problems. I have attached the number states as well as their what each one looks like. I for to tell you that the Rollstates have their own count as well.



All of these have been changed to number variable states.

Thanks for the help.

Side note if you want to see how this works in action here is the link to the game on GNOSTU | GDevelop game creator

So I fixed the issue I was having with this, but now when I export to an APK or HTML the touch controls do not work at all. When I preview the game in the engine it works when the mouse is over the buttons. I do not know what is going on. I have separated the keyboard functions and mobile touch controls and put them into separate object variables. Then put them in a into a sub condition variable boolean to check if the game is on mobile or not. Screenshot below. I appreciate the help guys.

The very first event has the action not to move the mouse cursor when touching the screen. The mouse cursor will move when a PC mouse movement, but not when it’s a touch.

You may be better off using the touch functions (new touch has started etc) for the touch only part. That should be simpler to implement now that you’ve separated the 2 input methods.

And as a suggestion, you can use an object group and place all the touch buttons in it. Then instead of deleting each mobile button object, you just delete the group and it’ll remove all objects that are in that group from the screen.

1 Like

Thanks for the help MrMen. I will put the buttons in the objects in a group. I did however find another way to activate the mobile in the booleans. I put them into a separate global variable and just activated the variables accordingly when the booleans are true.