Accelerometer Controls Roll Ball in Exact Direction of Tilt
JoshKahane
Member Posts: 470
Hi
I was wondering if it was possible to have it so that my ball in Trouball has tilt controls. But I don't just want tilt up and move up, left, right and down. Is it possible to have ti so that the ball moves in the very direction of the tilt? Any help much appreciated, thanks.
Kind regards,
Josh.
I was wondering if it was possible to have it so that my ball in Trouball has tilt controls. But I don't just want tilt up and move up, left, right and down. Is it possible to have ti so that the ball moves in the very direction of the tilt? Any help much appreciated, thanks.
Kind regards,
Josh.
Comments
something like this:
direction = angleToVector(accelerometerX, accelerometerY)
speed = 100*magnitude(accelerometerX, accelerometerY)
of course you'll want to play with the constant 100. Magnitude will be a normalized vector between 0 and 1. Of course, if you are viewing in landscape mode you'll need to transpose X and Y.
The rules would be the same for what I said before though, just use the Accelerate instead of the Move behavior but with the same direction and speed logic i stated above.
Of course, if you use accelerate you'll also want to add some Drag.
Darren.