View Full Version : controlling 3d movement from a virtual d-pad

02-05-2013, 10:25 AM

In my game I have a circle on screen indicating a steering wheel or direction pad. Depending on the position of the finger relative to the center of the circle, I want to move in that direction relative to my current 3D view. Given a 0-360 angle representing the position on the wheel, how do I figure out which way to move in 3D space?

I'm looking down on a 3D plane, and I want to move along it. I tried getting the Euler angles in YXZ order, so that it would give me the rotation around the Y axis of my current view. Then I changed that angle by the angle of my wheel. It sort of works, especially if I am down low, looking at less than a 45 degee angle. But up higher it gets out of whack. I am thinking this is because the Euler angles are not really a predictable way to measure? Or are they? I tried a similar thing with a quaternion for the camera rotation, but it did not work either.

Basically I am thinking that if I can determine an angle representing my current view's rotation around Y, then I can use that to figure out how to map my d-Pad direction to world space.

Thanks for any advice. There seems like there should be an easy way to do this, but my attempts have not worked so far.