Why the On-Screen buttons are freezing in Android?

I tested on-screen controls in Redmi Y2, Redmi Y3, Redmi Note 9 Pro, and RealMe Narzo 50a. The controls were freezing in all of them. I fixed the sprite points for the buttons and centered them correctly. Also, I tried using both the events with “trigger once” and without “trigger once” actions, and the buttons were still freezing. Like, sometimes they were working, sometimes not. Like, If I wanted to make the player jump and move forward, on one instance, it worked properly fine and the other time, it didn’t. I am not talking about the default controls that would run by using a keyboard. I am talking about the on-screen controls placed on the scene and testing them through real hardware. I checked my event sheet and the followings are the only events associated with touch and controls.

Why is this happening? You can download a test apk from this link: Clashing Bunny Bros Adventures-1_1_1 (12)

This is a verified error that occurred in all four of the devices that I used to test, the actual hardware devices and not some virtual emulators. I don’t know if this will appear on your end or not. I just want to know if this is a legit bug or if something wrong happened from my end or if am I missing to add something so that the buttons don’t freeze.

You have to give a bit more detail on what you are experiencing, right now people aren’t going to know what to check for on your link.

That said"the cursor/touch is on" events are for mouse input or mouse emulation only. A computer mouse cannot click on multiple locations at the same time, so those events will only allow one button to be pressed at any one time. Additionally “cursor/touch is on” events do not care about points or collision masks, it compares the cursor/virtual cursor to the aabb (full square) of the object.

If you are trying to set up multitouch controls, your easiest bet would be the multitouch joystick extension, which has button actions already designed for this, you can see it set up in the main platformwr example or the gundude example. For more detail on how it is built, you should look into the Multitouch example to understand using touch IDs.

Note that multitouch setup is complex compared to single touch/mouse emulation, but it will be required for what you seem to be trying to set up in your events.

The link is an apk file of the game that is facing the issue. You need to install this on an android device and try the gameplay to actually understand the error.

This is not about multi-touch. I haven’t mentioned multi-touch anywhere. This is simply about the buttons placed on the screen and connected with the events and actions shown in the screenshot above. There are three buttons, left, right, and jump. All these buttons are configured as shown in the event sheet screenshot above.

When I run the game and start a level, and start using those control buttons to move the character, sometimes it is working properly and accurately. Sometimes, it is just going dull, not responding, or freezing. You need to actually try that apk file out to understand what I am saying.

If the above setup for controls is wrong, what should be the appropriate setup or configuration for buttons that make characters move around without freezing in Android? What events or actions should I use so that those three buttons work properly without freezing or becoming unresponsive in the middle of the gameplay?

These buttons work at the beginning and while playing the game, suddenly they become unresponsive or freeze often at times, and then suddenly they start working. Sometimes they are working, sometimes they are not working. This is my problem in the example below.

There are two platforms at a certain distance. We need to jump from one platform to the other. So, I press the jump button and the right button to do that. In mid-air, without reaching the platform, the buttons go unresponsive. You know we need to hold that jump and right control to reach a certain distance. The buttons don’t work after a few milliseconds while holding them. And then they start working after a few seconds. That is the actual problem.

If you are lucky, they will work. If you are not, they will not work. I keep tapping and tapping on those controls and they didn’t work. And then after a few seconds, out of nowhere, they start working. This is the main problem. I got this problem in not just one device but 4 different devices. I checked other actions in the event sheet and they are not associated with either touch or the controls. The events mentioned above are the only events in my game associated with touch or controls.

This problem is not happening with just the jumping example given above. I press the right button and keep moving. Sometimes, it automatically stops moving. And all of these movements are done with the on-screen controls, the three buttons shown in the event sheet screenshot above. I call it being unresponsive or freezing.

So, if my events are wrong, what should I use instead that actually works? Correct me if I have made any mistakes in configuring these settings for the buttons.

Thank you for the details on the issue. Sorry for any confusion, I assumed you wanted multitouch because most games would have you jump and move in a direction at the same time. You won’t be able to do that without multitouch on a touch device (tablet/phone/etc).

That said, for single touch, I’d probably do the following:

Ignore the Name error on the condition, I just didn’t set up any objects for this.

Make sure none of your buttons overlap in the scene editor, and their collision masks are set up as expected (with no concave portions). Ensure that “UI” Is replaced with the layer name the buttons are on.

Outside of that, You might want to install and use the multitouch joystick extension anyway, it’s pretty simple if you do ever move on to having users.

If neither of these work, I can’t provide further guidance on what other events may be causing you issues, but someone else may be able to chime in.

1 Like

Hello, MaheshPanth!

How about the solution that we found in your another topic? Buttons Not Responding (Android) - #7 by MaheshPanth

Without condition “Touch or Left mouse button is down” and at the beggining of the scene making the cursor don’t move anymore with the touch screen, I can walk, jump and shoot using three fingers at the same time.

Hello, @Rasterisko Thank you for your response. Actually, that caused a different error. If I tap on the right button, the character would continuously moves to the right, even after the button is released. And, there was no way to stop the character. So, to fix that, I had to add the “touch or left mouse button is down” condition, it worked for a while, and suddenly it stopped working in some situations.

Hello, @Silver-Streak Thank you for putting some lights on the issue. I guess Multi-Touch is what I probably needed indeed. But I have some questions about this. My buttons are separate sprites and two of them shall be placed on the bottom left corner and two on the bottom right corner.

I have installed the Multi-Touch (Sprite) extension. Then I double-clicked on the “left” button and went to the behaviors tab. Then I got 3 options:

  1. Multitouch button
  2. Platformer Multitouch Controller Mapper
  3. Top-Down Multitouch Controller Mapper

What option should I select among these 3 to achieve the result described above? Should the controller identifier be the same or different for each button? And, I guess we need to add the button pressed or button released conditions to simulate the movements, is it true? When should we use the button pressed or button released conditions?

Thanks in advance.

The character moves continuously because the cursor stays on the button. If you add the first event of my screenshoot that prevents cursor movement when performing touches, this problem will not occur.

Hello again. I did the multi-touch configuration as below. Just in case, I have also added the multi-touch behavior to each of these individual sprites.

The problem is the same. Sometimes the buttons work smoothly, but sometimes they stuck. For example, I am pressing the right arrow. It will work for some time and then suddenly it will stop working for a few seconds in the middle of the gameplay. Then I have to tap again 3-4 times on the right button to make it work again. In simple words, it freezes in the middle of the gameplay.

As far as other conditions and events conflicting with this one, I have checked the entire event sheet from top to bottom, and to my knowledge, there are no other events associated with these controls. There are no variables causing touch issues or there are no such events that direct the controls to stop working at certain conditions.

Here is the apk file for testing. Without testing on real hardware, you won’t get it.

So I’ve done some separate testing and I cannot reproduce the issue you’re having when testing with any of the multitouch enabled examples I mentioned above, even exported as APK and installed. For one of the tests I took the platformer example, stretched a platform to be ~10 screen widths, and then tested with that to run right/left for an extended period of time.

Unfortunately, I do not install other user’s APKs as a matter of personal device security, so I won’t be able to test your provided apk. If someone else is willing to give it a shot and can reproduce it, it may somehow still be specific to your game.

You might also try exporting the platformer example to see if you experience it there. If you do, it is something specific to the hardware you’re testing on, if you don’t experience it with one of those, then it is still something specific to your project.

I tested on not just one but four different hardware: Redmi Y2, Redmi Y3, Redmi Note 9 Pro, and RealMe Narzo 50a. And, if testing is not possible for security reasons, then I have no words. Thanks for trying to help.

One last thing, how do I know that something is specific to my project? I have checked the event sheet, it’s clean, as far as I have the knowledge. Still, if I have done something wrong in my event sheet, I am ready to provide all the details you need in the event sheet. As far as conflicts with other behavior is concerned, I am using Physics 2.0 with Platformer behavior. The Physics 2.0 behavior is turned off initially and activated only when needed. What else can cause this conflict?

The way that I mentioned above (exporting one of the example projects with touch controls and testing there) would be the fastest and easiest way to test if it’s something with your project. If it works normally in the example projects but not yours, it is something with either your logic, behaviors, or objects.

You mentioned using both physics and platformer on the same object, keep in mind that the behaviors are designed to only have one movement behavior enabled at any one time. If you have both the platformer and physics behaviors enabled at the same time (even if you’re disabling the physics behavior and only enabling it when needed) that can cause issues.

Additionally, ensure you are disabling default controls on the platformer behavior, even though you’re using touch inputs, I’ve seen oddities where you do anything that involves simulating inputs but still have the default controls enabled.

Outside of the above, I don’t have any other suggestions that I can think of at this time.

As I said above, Physics 2.0 is turned off or deactivated initially, at the beginning of the scene and activated only when needed. I don’t have both enabled or activated at the same time. Before exporting the apk files, I make sure that the default controls are turned off. I am using Physics 2.0 behavior for certain reasons only, to achieve some specific needs.

I am getting problems with the project I created, not the example files. That’s why I am asking what is causing the problem and how to fix it. I even said that I am ready to provide the complete project file. There’s a difference between testing an example file and a complete project. So, if anything else is conflicting with my project, I want to know, what is that?

If it cannot be fixed, analyzed, or tested, then that’s it. Four devices, of different Android versions, are giving the same error. I even play Call of Duty on Redmi Note 9 Pro, one of the devices mentioned above, and never had any problems with the touch or sensitivity.

So, if you are not willing to test the file, then thank you very much for trying to help. Maybe, someone else could. And, if you don’t mind, can you please mention some example files that contain long platformer levels, not short ones, like the ones we can play for 2-3 minutes so that I can properly test if it’s my hardware or something else causing the issue? Like, we cannot test it on examples that have short length levels, that last only for a few seconds.

The actual games that we produce are different than the example files, in terms of level length, the extensions used, the number of sprites, variables, and all those things. The actual game that is released to the public is long. They don’t end in 5 to 10 seconds. So, if you can do something, like sending an example that has longer levels, made for Android or touch screens for testing purposes, that’d be great.

I totally understand that the use of multiple extensions, behavior, or heavy scripts or files can cause these problems, I just want to know what is it.

Thanks again.

Update: The solution given by @Rasterisko worked. Thank you very much :grin: I will post an update here if anything goes wrong in the future. Sorry for any trouble @Silver-Streak