Hello, dear creators!
Who can tell me how to make SMOOTH tilt control to left and right (more tilt, more speed.) for platform game. For example, like in DoodleJump or any SpaceShooter.
Somebody please reply who have made Left & Right smooth mobile tilt controls. I'm so tired looking for such an easy solution.
Thank you in advance.
Touch.Gamma gives the tilt of the device, mess around with that. If you want to make it smoother look into interpolation.
briggybros, unfortunatelly your answer wasn't helpful.
Develop games in your browser. Powerful, performant & highly capable.
There could be two different controls, one would change the "Speed" with the tilt, while other would change the "X position" based on tilt, here is how you can implement both:
For speed (assuming you already have a speed variable)
Set Value (Speed) to Speed + Touch.Gamma
if it is too sensitive and moving too fast, then make it Speed + Touch.Gamme/2 (divide by a number)
if you wish to change the X position based on the amount of tilt then:
Set X of Player to Player.X + Touch.Gamma*10 (multiply by a number to be able to reach both ends of the screen)
I'm not sure about the multiplier or divide values, it depends on your game and Touch values, so you will have to experiment and fine-tune with some trial & errors. Good luck.