I’ve got this code attached to a 2D sprite that I want to rotate. So far I’m working on making it rotate left when the left arrow key is pressed. I get no parsing errors, but when I run the game, the code doesn’t work. Any idea what I’m doing wrong?
using UnityEngine;
using System.Collections;
public class Rotate : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown ("left"))
RotateLeft();
}
void RotateLeft () {
Quaternion theRotation = transform.localRotation;
theRotation.z *= 270;
transform.localRotation = theRotation;
}
}