I have a button
and a PlayerObject
. When I click the button, the object must rotate continuously, and when I click the same button again, the object must stop rotating. Currently, I am using the code given below. It makes the object only rotate once to a certain angle.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
int a=1;
public void CubeRotate () {
a++;
transform.Rotate (new Vector3 (150, 300, 60) * Time.deltaTime);
if (a%2==0) {
Debug.Log(a);
transform.Rotate (new Vector3 (150, 300, 60) * Time.deltaTime);
}
}
}
Please help. Thanks in advance.