public override void OnStateUpdate(FirstPersonBrain firstPerson) { var groundCheck = firstPerson.groundCheck; groundCheck.CheckGround(); if (groundCheck.IsGrounded && !groundCheck.IsOnSteepSlope()) { firstPerson.motor.MoveOnGround(groundCheck.GroundHit.normal, firstPerson.Movement); if (firstPerson.IsJumped) { firstPerson.TransitionToState(firstPerson.JumpingState); } else if (firstPerson.Movement == Vector2.zero) { firstPerson.TransitionToState(firstPerson.IdleState); } } else { firstPerson.motor.SnapToGround( groundCheck.GroundDistance, groundCheck.groundCheckDistance, firstPerson.motor.snapToGroundDistance); firstPerson.motor.ApplyGravity(); } }
public override void OnStateUpdate(FirstPersonBrain firstPerson) { var groundCheck = firstPerson.groundCheck; groundCheck.CheckGround(); if (groundCheck.IsGrounded && Time.fixedTime > _nextJumpTime) { if (firstPerson.Movement == Vector2.zero) { firstPerson.TransitionToState(firstPerson.IdleState); } else { firstPerson.TransitionToState(firstPerson.RunningState); } } else { firstPerson.motor.MoveInAir(firstPerson.Movement); firstPerson.motor.ApplyGravity(); } }
public override void OnStateEnter(FirstPersonBrain firstPerson) { }
public override void OnStateEnter(FirstPersonBrain firstPerson) { firstPerson.motor.Jump(); _nextJumpTime = Time.fixedTime + 0.2f; }
public abstract void OnStateExit(FirstPersonBrain firstPerson);
public abstract void OnStateUpdate(FirstPersonBrain firstPerson);