示例#1
0
 //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;
     }
 }
示例#2
0
    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;
        }
    }
示例#3
0
    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;
            }
        }
    }
示例#4
0
    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;
            }
        }
    }
示例#5
0
 void SetState(RotateStates newState)
 {
     curState = newState;
 }