コード例 #1
0
        public void AttackTargets(Collider[] targets)
        {
            foreach (var target in targets)
            {
                this.target = target.gameObject;
            }

            var   animationClip     = currentWeaponConfig.GetRandomAttackAnimClip();
            float animationClipTime = animationClip.length / character.GetAnimSpeedMultiplier();
            float timeToWait        = animationClipTime + currentWeaponConfig.GetTimeBetweenAnimationCycles();

            bool isTimeToHitAgain = (Time.time - lastHitTime) > timeToWait;

            if (isTimeToHitAgain)
            {
                SetAttackAnimation();
                animator.SetTrigger(ATTACK_TRIGGER);
                lastHitTime = Time.time;
            }
        }