Circular Analog Input?

Hello,

I need a character to face the direction the player is pressing on an analog stick. I know how to get the input axes from a joystick, but no matter how I try to get any angle or anything from them, the input range comes out square. I would presume some trigonometry has something to do with the correct answer. Any ideas?

Thanks!

// C# or UnityScript(JS)
var direction = new Vector3( Input.GetAxis (“Horizontal”), 0, Input.GetAxis (“Vertical”) );

transform.forward = direction;

An alternative:

// this gives you more control over the rotation around the look axis if needed
var direction = new Vector3( Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical") );
var rotation = Quaternion.LookRotation(direction, Vector3.up);
transform.rotation = rotation;