Example #1
0
        public override void UpdateBehaviour(float dt)
        {
            switch (state)
            {
            case LadderClimbState.Entering:

                CharacterActor.Position = targetPosition;
                CharacterStateController.UseRootMotion = true;
                CharacterStateController.Animator.SetTrigger(isBottom ? bottomUpParameter : topDownParameter);

                state = LadderClimbState.AnimationBased;

                break;

            case LadderClimbState.AnimationBased:

                if (CharacterStateController.Animator.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
                {
                    if (CharacterActions.interact.Started)
                    {
                        forceExit = true;
                    }
                    else
                    {
                        if (CharacterActions.movement.Up)
                        {
                            if (currentClimbingAnimation == currentLadder.ClimbingAnimations)
                            {
                                CharacterStateController.Animator.SetTrigger(topUpParameter);
                            }
                            else
                            {
                                CharacterStateController.Animator.SetTrigger(upParameter);
                                currentClimbingAnimation++;
                            }
                        }
                        else if (CharacterActions.movement.Down)
                        {
                            if (currentClimbingAnimation == 0)
                            {
                                CharacterStateController.Animator.SetTrigger(bottomDownParameter);
                            }
                            else
                            {
                                CharacterStateController.Animator.SetTrigger(downParameter);
                                currentClimbingAnimation--;
                            }
                        }
                    }
                }
                else if (CharacterStateController.Animator.GetCurrentAnimatorStateInfo(0).IsName("Entry"))
                {
                    forceExit = true;
                    CharacterActor.ForceGrounded();
                }

                break;
            }
        }
Example #2
0
        public override void EnterBehaviour(float dt, CharacterState fromState)
        {
            CharacterActor.IsKinematic       = true;
            CharacterActor.AlwaysNotGrounded = true;
            CharacterActor.Velocity          = Vector3.zero;


            currentClimbingAnimation = isBottom ? 0 : currentLadder.ClimbingAnimations;

            targetPosition = isBottom ? currentLadder.BottomReference.position : currentLadder.TopReference.position;

            CharacterActor.Forward = currentLadder.FacingDirectionVector;

            state = LadderClimbState.Entering;
        }