so im making a slot machine game and i have the wheels spinning but i want it when the button is pressed and it wont seem to do it:
public int wheelspin = 360;
bool areWeSpinning = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Space) && (areWeSpinning == true ));
if (areWeSpinning == true) transform.Rotate(Vector3.right * Time.deltaTime * wheelspin);
}
}
can anyone help please
You’re terminating your if statements prematurely, use indenting and curly braces to show scope such as:
public int wheelspin = 360;
bool areWeSpinning = false;
// Use this for initialization
void Start () {
// if you're not using methods that are part of unity's state machine you should delete them so empty methods aren't invoked.
}
// Update is called once per frame
void Update () {
// You're already checking areWeSpinning once, don't do it again. Don't term the if statement by ending the IF statement with a semicolon.
if ( Input.GetKey(KeyCode.Space) && areWeSpinning == true ) {
transform.Rotate(Vector3.right * Time.deltaTime * wheelspin);
}
}