Exemple #1
0
        public override void Execute(StateManager states)
        {
            VaultData v = states.vaultData;

            if (!v.isInit)
            {
                v.vaultTime = 0;
                v.isInit    = true;
                Vector3 dir = v.endingPosition - v.startPosition;
                dir.y = 0;
                Quaternion rot = Quaternion.LookRotation(dir);
                states.mTransform.rotation = rot;
            }
            float actualSpeed = (states.delta * v.vaultSpeed) / v.animLength;

            v.vaultTime += actualSpeed;

            if (v.vaultTime > 1)
            {
                v.isInit          = false;
                states.isVaulting = false;
            }
            Vector3 targetPosition = Vector3.Lerp(v.startPosition, v.endingPosition, v.vaultTime);

            states.mTransform.position = targetPosition;
        }
 public void InitReferences()
 {
     mTransform        = this.transform;
     rigidbody         = GetComponent <Rigidbody>();
     anim              = GetComponentInChildren <Animator>();
     hashes            = new AnimHashes();
     vaultData         = new VaultData();
     coverData         = new CoverData();
     stats.health      = 100;
     healthChangedFlag = true;
     characterHook     = GetComponentInChildren <CharacterHook>();
 }
        public override void Execute(StateManager states)
        {
            VaultData v = states.vaultData;

            Debug.Log("Vault state is active");
            if (!v.isInit)
            {
                v.vaultT = 0;
                v.isInit = true;
            }

            v.vaultT += states.delta * v.vaultSpeed;

            if (v.vaultT > 1)
            {
                v.isInit          = false;
                states.isVaulting = false;
            }

            Vector3 targetPosition = Vector3.Lerp(v.startPosition, v.endingPosition, v.vaultT);

            states.mTransform.position = targetPosition;
        }