public override void OnUpdate(MainPlayerMovementFSM playerFSM) { if (Mathf.Abs(playerFSM.horizontalInput) == 0 && Mathf.Abs(playerFSM.verticalInput) == 0) { playerFSM.EnterState(playerFSM.idleState, true); return; } if (Input.GetKeyDown(KeyCode.Space)) { playerFSM.EnterState(playerFSM.jumpingState, true); return; } if (Input.GetKey(KeyCode.Mouse0)) { playerFSM.EnterState(playerFSM.attackingReadyState, true); return; } if (Input.GetKeyDown(KeyCode.LeftShift) && playerFSM.IsMoving()) { Debug.Log("Shift pressed!"); playerFSM.EnterState(playerFSM.rollingState, true); } }
public override void OnUpdate(MainPlayerMovementFSM playerFSM) { timerTime += Time.deltaTime; if (timerTime >= playerFSM.timeBeforeRollCompleted) { playerFSM.anim.SetTrigger("RollingEnds"); playerFSM.EnterState(playerFSM.idleState, true); } }
public override void OnUpdate(MainPlayerMovementFSM playerFSM) { //playerFSM.Move(); if (Mathf.Abs(playerFSM.horizontalInput) > 0 || Mathf.Abs(playerFSM.verticalInput) > 0) { playerFSM.EnterState(playerFSM.runningState, true); return; } if (Input.GetKeyDown(KeyCode.Space)) { playerFSM.EnterState(playerFSM.jumpingState, true); return; } if (Input.GetKey(KeyCode.Mouse0)) { playerFSM.EnterState(playerFSM.attackingReadyState, true); return; } }
public override void OnFixedUpdate(MainPlayerMovementFSM playerFSM) { if (playerFSM.AirControl) { playerFSM.MoveFixed(); } if (timerTime >= timeBeforeJumpCheck) { isJumping = true; } if (isJumping) { Collider[] colliders = Physics.OverlapSphere(playerFSM.GroundCheckPoint.position, playerFSM.GroundCheckRadius, playerFSM.GroundMask); if (colliders.Length > 0) { isJumping = false; playerFSM.EnterState(playerFSM.idleState, true); } } }