void CheckForTriggerAction(Collider other)
        {
            // assign the component - it will be null when he exit the trigger area
            var _ladderAction = other.GetComponent <vTriggerLadderAction>();

            if (!_ladderAction)
            {
                return;
            }
            // check the maxAngle too see if the character can do the action
            var dist = Vector3.Distance(transform.forward, _ladderAction.transform.forward);

            if (isUsingLadder && _ladderAction != null)
            {
                ladderAction = _ladderAction;
            }
            else if (dist <= 0.8f && !isUsingLadder)
            {
                ladderAction = _ladderAction;
                ladderAction.OnPlayerEnter.Invoke();
            }
            else
            {
                if (ladderAction != null)
                {
                    ladderAction.OnPlayerExit.Invoke();
                }
                ladderAction = null;
            }
        }
        void TriggerEnterLadder()
        {
            if (debugMode)
            {
                Debug.Log("Enter Ladder");
            }

            OnEnterLadder.Invoke();
            triggerEnterOnce = true;
            isUsingLadder    = true;
            tpInput.cc.animator.SetInteger("ActionState", 1);     // set actionState 1 to avoid falling transitions
            tpInput.enabled    = false;                           // disable vThirdPersonInput
            tpInput.cc.enabled = false;                           // disable vThirdPersonController, Animator & Motor
            tpInput.cc.DisableGravityAndCollision();              // disable gravity & turn collision trigger
            tpInput.cc._rigidbody.velocity = Vector3.zero;
            tpInput.cc.isGrounded          = false;
            tpInput.cc.animator.SetBool("IsGrounded", false);
            ladderAction.OnDoAction.Invoke();

            ladderActionTemp = ladderAction;

            if (!string.IsNullOrEmpty(ladderAction.playAnimation))
            {
                tpInput.cc.animator.CrossFadeInFixedTime(ladderAction.playAnimation, 0.1f);     // trigger the action animation clip
            }
        }
Exemplo n.º 3
0
        void TriggerEnterLadder()
        {
            if (debugMode)
            {
                Debug.Log("Enter Ladder");
            }

            OnExitTriggerLadder.Invoke();

            if (ladderAction.targetCharacterParent)
            {
                transform.parent = ladderAction.targetCharacterParent;
            }
            tpInput.cc.isCrouching = false;
            tpInput.cc.ControlCapsuleHeight();
            tpInput.UpdateCameraStates();
            tpInput.cc.UpdateAnimator();
            OnEnterLadder.Invoke();
            triggerEnterOnce = true;
            isEnterLadder    = true;
            tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 1);     // set actionState 1 to avoid falling transitions
            tpInput.SetLockAllInput(true);
            tpInput.cc.ResetInputAnimatorParameters();
            ladderAction.OnDoAction.Invoke();
            ladderActionTemp = ladderAction;
            tpInput.cc.animator.updateMode = AnimatorUpdateMode.Normal;
            if (!string.IsNullOrEmpty(ladderActionTemp.playAnimation))
            {
                tpInput.cc.animator.CrossFadeInFixedTime(ladderActionTemp.playAnimation, 0.25f);     // trigger the action animation clip
                isUsingLadder = true;
                tpInput.cc.disableAnimations = true;
                tpInput.cc.StopCharacter();
                isEnterLadder = false;
            }
        }
Exemplo n.º 4
0
        public virtual void ResetPlayerSettings()
        {
            if (debugMode)
            {
                Debug.Log("Reset Player Settings");
            }

            speed = 0f;
            targetLadderAction = null;
            isUsingLadder      = false;
            OnExitLadder.Invoke();
            triggerExitOnce        = false;
            triggerEnterOnce       = false;
            inEnterLadderAnimation = false;
            enterLadderStarted     = false;
            tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 0);
            tpInput.cc.EnableGravityAndCollision();
            tpInput.SetLockAllInput(false);
            tpInput.cc.StopCharacter();
            tpInput.cc.disableAnimations   = false;
            tpInput.cc.animator.updateMode = AnimatorUpdateMode.AnimatePhysics;
            if (transform.parent != null)
            {
                transform.parent = null;
            }
        }
Exemplo n.º 5
0
        protected virtual void CheckForTriggerAction(Collider other)
        {
            // assign the component - it will be null when he exit the trigger area
            var _ladderAction = other.GetComponent <vTriggerLadderAction>();

            if (!_ladderAction)
            {
                return;
            }
            // check the maxAngle too see if the character can do the action
            var dist = Vector3.Distance(transform.forward, _ladderAction.transform.forward);

            if (isUsingLadder && _ladderAction != null)
            {
                if (targetLadderAction != _ladderAction)
                {
                    targetLadderAction = _ladderAction;
                    if (!actionTriggers.Contains(targetLadderAction))
                    {
                        actionTriggers.Add(targetLadderAction);
                    }
                }
            }
            else if ((_ladderAction.activeFromForward == false || dist <= 0.8f) && !isUsingLadder)
            {
                AddLadderTrigger(_ladderAction);
                OnEnterTriggerLadder.Invoke();
            }
            else
            {
                RemoveLadderTrigger(_ladderAction);
            }
        }
 public override void OnActionExit(Collider other)
 {
     if (other.gameObject.CompareTag(actionTag))
     {
         // disable ingame hud
         if (ladderAction != null)
         {
             ladderAction.OnPlayerExit.Invoke();
         }
         ladderAction = null;
     }
 }
Exemplo n.º 7
0
        protected virtual void RemoveLadderTrigger(vTriggerLadderAction _ladderAction)
        {
            if (_ladderAction == targetLadderAction)
            {
                targetLadderAction = null;
            }

            if (actionTriggers.Contains(_ladderAction))
            {
                actionTriggers.Remove(_ladderAction);
                _ladderAction.OnPlayerExit.Invoke();
            }
        }
Exemplo n.º 8
0
        protected virtual void AddLadderTrigger(vTriggerLadderAction _ladderAction)
        {
            if (targetLadderAction != _ladderAction)
            {
                targetLadderAction = _ladderAction;
                if (debugMode)
                {
                    Debug.Log("TriggerStay " + targetLadderAction.name + "_" + targetLadderAction.transform.parent.gameObject.name);
                }
            }

            if (!actionTriggers.Contains(targetLadderAction))
            {
                actionTriggers.Add(targetLadderAction);
                targetLadderAction.OnPlayerEnter.Invoke();
            }
        }
 void ResetPlayerSettings()
 {
     if (debugMode)
     {
         Debug.Log("Reset Player Settings");
     }
     speed         = 0f;
     ladderAction  = null;
     isUsingLadder = false;
     OnExitLadder.Invoke();
     triggerExitOnce  = false;
     triggerEnterOnce = false;
     tpInput.cc._capsuleCollider.isTrigger = false;
     tpInput.cc._rigidbody.useGravity      = true;
     tpInput.cc.animator.SetInteger("ActionState", 0);
     tpInput.cc.enabled = true;
     tpInput.enabled    = true;
     tpInput.cc.gameObject.transform.eulerAngles = new Vector3(0f, tpInput.cc.gameObject.transform.localEulerAngles.y, 0f);
 }
Exemplo n.º 10
0
 public void ResetPlayerSettings()
 {
     if (debugMode)
     {
         Debug.Log("Reset Player Settings");
     }
     speed         = 0f;
     ladderAction  = null;
     isUsingLadder = false;
     OnExitLadder.Invoke();
     triggerExitOnce  = false;
     triggerEnterOnce = false;
     tpInput.cc.animator.SetInteger(vAnimatorParameters.ActionState, 0);
     tpInput.cc._rigidbody.useGravity      = true;
     tpInput.cc._capsuleCollider.isTrigger = false;
     tpInput.SetLockAllInput(false);
     tpInput.cc.StopCharacter();
     tpInput.cc.disableAnimations = false;
 }
Exemplo n.º 11
0
        void ExitLadderInput()
        {
            if (!isUsingLadder)
            {
                return;
            }
            if (tpInput.cc.baseLayerInfo.IsName("EnterLadderTop") || tpInput.cc.baseLayerInfo.IsName("EnterLadderBottom"))
            {
                return;
            }

            if (ladderAction == null)
            {
                if (tpInput.cc.IsAnimatorTag("ClimbLadder"))
                {
                    if (slideDownInput.GetButtonDown() && !isExitingLadder)
                    {
                        tpInput.cc.animator.CrossFadeInFixedTime("Ladder_SlideDown", 0.2f);
                    }

                    // exit ladder at any moment by pressing the cancelInput
                    if (exitInput.GetButtonDown())
                    {
                        if (debugMode)
                        {
                            Debug.Log("Quick Exit");
                        }
                        tpInput.cc.animator.speed = 1;
                        tpInput.cc.animator.CrossFadeInFixedTime("QuickExitLadder", 0.1f);
                        Invoke("ResetPlayerSettings", .5f);
                    }
                }
            }
            else
            {
                ladderActionTemp = ladderAction;
                var animationClip = ladderAction.exitAnimation;
                if (animationClip == "ExitLadderBottom")
                {
                    // exit ladder when reach the bottom by pressing the cancelInput or pressing down at
                    if (exitInput.GetButtonDown() && !triggerExitOnce || (speed <= -0.05f && !triggerExitOnce) || (tpInput.cc.IsAnimatorTag("LadderSlideDown") && ladderAction != null && !triggerExitOnce))
                    {
                        if (debugMode)
                        {
                            Debug.Log("Exit Bottom");
                        }
                        triggerExitOnce = true;
                        tpInput.cc.animator.CrossFadeInFixedTime(ladderAction.exitAnimation, 0.1f);             // trigger the animation clip
                    }
                }
                else if (animationClip == "ExitLadderTop" && tpInput.cc.IsAnimatorTag("ClimbLadder"))    // exit the ladder from the top
                {
                    if ((speed >= 0.05f) && !triggerExitOnce && !tpInput.cc.animator.IsInTransition(0))  // trigger the exit animation by pressing up
                    {
                        if (debugMode)
                        {
                            Debug.Log("Exit Top");
                        }
                        triggerExitOnce = true;
                        tpInput.cc.animator.CrossFadeInFixedTime(ladderAction.exitAnimation, 0.1f);             // trigger the animation clip
                    }
                }
            }
        }