unity engine cant rotate in editor code example
Example 1: how to change rotate with script unity
var rotationVector = transform.rotation.eulerAngles;
rotationVector.z = 0;
transform.rotation = Quaternion.Euler(rotationVector);
Example 2: rotate player unity
public class Test : MonoBehaviour
{
public float RotateSpeed = 30f;
void Update ()
{
if (Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(-Vector3.up * RotateSpeed * Time.deltaTime);
else if (Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up * RotateSpeed * Time.deltaTime);
}
}