One-Line Mobile Control Fix


The May 18th update slightly broke mobile controls. I want to show you what I had and what I changed to make it work better. 

First, the problem. bHopper on mobile uses a virtual joystick, a very helpful prebuilt asset in GDevelop. Testing the latest update, I realized that the player's car would just stop moving. 

Here's the event group:

Right-click and open in new tab to enlarge.

In plain language, here's what's happening: 

  • The game notices that the player is touching the joystick. 
  • "Aha," the game says. 
  • It looks at the angle of the stick, and converts it. The joystick operates in a range of -180 to 180, and I want it to be 0 to 360. 
  • Depending on whether the angle of the stick is greater or less than the angle the car is facing, the car will rotate left or right towards the stick's angle at the rate of the car's handling. 
  • The car moves forward at a speed consistent with how far you're pushing the stick. 

I realized pretty quickly that my problem was that first condition: The cursor/touch is on TransparentDarkJoystick. On a gamepad, that makes sense. You only need to really deal with input when input is happening. In fact, that's how I do it: 

Right-click and open in new tab to enlarge.

But the difference between a glass touchscreen and a rubberized thumbstick is that on the stick, your finger doesn't slip and slide around. You adhere to the thumbstick. On glass, you can easily slide off. So any time my thumb came off the stick, the cursor/touch is on TransparentDarkJoystick condition was no longer met, so the turning and thrust stopped. 

Want to see my brilliant fix?

Right-click and open in new tab to enlarge.

Yeah, I deleted the cursor/touch condition. That's all I did. Now it's just always applying appropriate rotation and thrust, so my thumb can slide off the virtual joystick and it'll work as intended. I'll likely try to replicate the stick force condition from the gamepad controls on the virtual joystick, just so that I'm not running those events when I don't have to. But the controls feel much better now. 

Oh, and I fixed the crummy explosion. I should add more of those. 

Files

bHopper-2025-05-21.zip Play in browser
46 days ago

Leave a comment

Log in with itch.io to leave a comment.