# Using Quaternion

I am trying to make my sprite rotate based on where the left stick is pointing. I’m trying to use Quaternions to rotate but I believe my lack of knowlege in maths is making trying to understand the documentation a bit difficult. Can anybody see what i’m doing with wrong and point me towards good resources for learning this kind of stuff.

``````void Update ()
{
float x_pos = Input.GetAxis("Horizontal");
float y_pos = Input.GetAxis("Vertical");
rotation (x_pos,y_pos);
movement (x_pos,y_pos);
}

void movement ( float x ,float y )
{
if (x > 0) transform.Translate(Vector3.right * speed * Time.deltaTime);
if (x < 0 ) transform.Translate(Vector3.left * speed * Time.deltaTime);
if (y > 0) transform.Translate(Vector3.up * speed * Time.deltaTime);
if (y < -0) transform.Translate(Vector3.down * speed * Time.deltaTime);
}

void rotation ( float x ,float y )
{

float angle_rotate = Mathf.Sqrt(Mathf.Pow(x,2)+Mathf.Pow(y,2));
Quaternion rotate = Quaternion.Euler(0, 0, angle_rotate*360);
Debug.Log (rotate);
transform.rotation = rotate;

}
``````

``````float rot_z = Mathf.Atan2(y_pos, x_pos) * Mathf.Rad2Deg;