//inactive state for when you aren't in the air void StateInactive() { //if in air if (!RCon.GetGTASwitch()) { //sets the state to back leaning rotation curState = RotateStates.BackState; } }
private void Update() { //calls current state every update frame fsm[curState].Invoke(); //timer timePassed += Time.deltaTime; //sets current rotation for checking quaternion curRot = transform.rotation; //if on the ground if (RCon.GetGTASwitch()) { //set state to inactive(not rotating in air) curState = RotateStates.inactiveState; } }
void StateFor() { //sets rotation for forward leaning rotation and says it is leaning forward isFor = true; transform.rotation = Quaternion.Slerp(transform.rotation, forRot, speed * Time.deltaTime); //allows for changing rotatin in air after timer is done if (timePassed > timer && inAir) { if (Input.GetKeyDown(KeyCode.A)) { //resets timer and changes state ResetTimePassed(); curState = RotateStates.MidState; } } }
void StateMid() { //sets rotation for neutral in air and says it isn't leaning forward isFor = false; transform.rotation = Quaternion.Slerp(transform.rotation, midRot, speed * Time.deltaTime); //allows for changing rotatin in air after timer is done if (timePassed > timer && inAir) { if (Input.GetKeyDown(KeyCode.D)) { //resets timer and changes state ResetTimePassed(); curState = RotateStates.ForState; } if (Input.GetKeyDown(KeyCode.A)) { //resets timer and changes state ResetTimePassed(); curState = RotateStates.BackState; } } }
void SetState(RotateStates newState) { curState = newState; }