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