rotate unity 2d code example
Example 1: rotation unity script 2d
transform.eulerAngles = Vector3.forward * degrees;
transform.rotation = Quaternion.Euler(Vector3.forward * degrees);
transform.rotation = Quaternion.LookRotation(Vector3.forward, yAxisDirection);
transform.LookAt(Vector3.forward, yAxisDirection);
transform.right = xAxisDirection;
transform.up = yAxisDirection;
Example 2: rotation unity script 2d
transform.Rotate(Vector3(0, 0, 50));
transform.eulerAngles = new Vector3 (0, 0, 50);
transform.eulerAngles = Vector3.forward * 50;
Example 3: 2d rotation unity
float x;
void Update ()
{
x += Time.deltaTime * 10;
transform.rotation = Quaternion.Euler(x,0,0);
}