示例#1
0
        void TriggerEnterLadder()
        {
            if (debugMode)
            {
                Debug.Log("Enter Ladder");
            }

            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
            }
        }
示例#2
0
        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;
            }
        }
示例#3
0
 public override void OnActionExit(Collider other)
 {
     if (other.gameObject.CompareTag(actionTag))
     {
         // disable ingame hud
         if (ladderAction != null)
         {
             ladderAction.OnPlayerExit.Invoke();
         }
         ladderAction = null;
     }
 }
示例#4
0
 void ResetPlayerSettings()
 {
     if (debugMode)
     {
         Debug.Log("Reset Player Settings");
     }
     speed            = 0f;
     ladderAction     = null;
     isUsingLadder    = false;
     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);
 }