I want to be able to press a button and have my gameObject be constantly rotating on the y-axis. When I press the same button again, I want my gameObject to stop rotating. Here’s is what I have so far.
public int speed;
void Update(){
if (Input.GetKey (KeyCode.W)) {
transform.Rotate (Vector3.up * Time.deltaTime * speed );
}
}
When I press W it will start to rotate but stop with I let go of the button.