Q:

rotation unity script 2d

transform.Rotate(Vector3(0, 0, 50));
//instead of :
transform.eulerAngles = new Vector3 (0, 0, 50);
//or like you said
transform.eulerAngles = Vector3.forward * 50;
0
// Rotation scripting with Euler angles correctly.
// Store the Euler angle in a class variable, and only use it to
// apply it as a Euler angle, but never rely on reading the Euler back.
        
float x;
void Update () 
    {
        x += Time.deltaTime * 10;
        transform.rotation = Quaternion.Euler(x,0,0);
    }
1
transform.eulerAngles = Vector3.forward * degrees;
// or
transform.rotation = Quaternion.Euler(Vector3.forward * degrees);
// or
transform.rotation = Quaternion.LookRotation(Vector3.forward, yAxisDirection);
// or
transform.LookAt(Vector3.forward, yAxisDirection);
// or
transform.right = xAxisDirection;
// or
transform.up = yAxisDirection;
1

New to Communities?

Join the community