Rotation with accelerometer

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Petia Davidova
:warning: Old Version Published before Godot 3 was released.

Hello,

I am trying to make my first game ever. The basic idea is there is a ball with initial direction and speed, going up at some angle, not falling, and it bounces off the edges of the screen. The player tilts their phone and the ball’s bounce direction depends on the incline of the phone. I managed to get the data from the accelerometer and transform it to angles, although it is undefined for some angles, but I can’t figure out how to change the ball’s movement direction according to the incline. I want the ball to keep it’s direction regardless of the incline, like in the picture, and then “bounce” off the screen edge at an angle. I think I need to change the movement vector when the phone incline changes but I am not sure how to do it. Any ideas would be appreciated! Thanks

I don’t think your picture embedded properly.

keke | 2017-09-05 01:33