I've currently got a simple rotation on an object through code using eulerAngles, like this (This is just a quick example):
float rotateSpeed = 200;
float rotateZ = 0.0f;
public KeyCode FTurn;
void FNotation(){
if (Input.GetKeyDown(FTurn)){
GetComponent<Transform>().eulerAngles = new Vector3(0.0f, 0.0f, rotateZ += 90f)
}
}
void Update(){
FNotation();
}
This code works fine as it rotates my object when I press 'F'. The only issue is that it performs this function in 1 frame due to the Update function, I know I can make animations and call these when pressed instead, but I wanted to know if there's a way through code for the cube to visually rotate instead of just in 1 frame?
When I press or hold the F key, my object rotates by 90 degrees but only in 1 frame, however I want the object to visually rotate 90 degrees only when I've pressed the 'F' key once! I do not want to be able to hold the key whilst the object is constantly spinning.