Example #1
0
        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();
            }
        }
Example #2
0
        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();
            }
        }
Example #3
0
 public override void OnStateEnter(FirstPersonBrain firstPerson)
 {
 }
Example #4
0
 public override void OnStateEnter(FirstPersonBrain firstPerson)
 {
     firstPerson.motor.Jump();
     _nextJumpTime = Time.fixedTime + 0.2f;
 }
Example #5
0
 public abstract void OnStateExit(FirstPersonBrain firstPerson);
Example #6
0
 public abstract void OnStateUpdate(FirstPersonBrain firstPerson);