コード例 #1
0
ファイル: Enemy.cs プロジェクト: RosieMable/Final_Game
        protected virtual void Awake()
        {
            rigidBody             = GetComponent <Rigidbody>();
            rigidBody.angularDrag = 999;
            rigidBody.drag        = 4;
            rigidBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
            charAnim               = GetComponentInChildren <Animator>();
            animHook               = GetComponentInChildren <AnimatorHook>();
            agent                  = GetComponent <NavMeshAgent>();
            agent.speed            = speed;
            agent.stoppingDistance = attackRange;
            healthSlider           = GetComponentInChildren <Slider>();
            healthSlider.maxValue  = currentHealth;
            healthSlider.value     = currentHealth;
            healthSlider.gameObject.SetActive(false);
            damageText = GetComponentInChildren <TextMeshProUGUI>();
            damageText.gameObject.SetActive(false);
            characterAudioSource = GetComponent <AudioSource>();
            maximumHealth        = currentHealth;

            //if (animHook == false)
            //{
            //    print("Added AnimatorHook.cs to " + gameObject.name);
            //    charAnim.gameObject.AddComponent<AnimatorHook>();
            //}
        }
コード例 #2
0
        /// <summary>
        /// Performs set up references for variables needed for class methods.
        /// </summary>
        public void Initialise()
        {
            SetUpAnimator();
            rigidBody             = GetComponent <Rigidbody>();
            rigidBody.angularDrag = 999;
            rigidBody.drag        = 4;
            rigidBody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
            animHook             = GetComponentInChildren <AnimatorHook>();
            collider             = GetComponent <Collider>();
            characterAudioSource = GetComponent <AudioSource>();
            shieldAudioSource    = GameObject.Find("Shield").GetComponent <AudioSource>();
            originalSpeed        = moveSpeed;

            if (animHook == false)
            {
                //print("Added AnimatorHook.cs to " + gameObject.name);
                animHook = activeModel.AddComponent <AnimatorHook>();
            }

            animHook.Initialise(this, null);
            actionManager = GetComponent <ActionManager>();
            actionManager.Initialise();
            weaponHook = GetComponentInChildren <WeaponHook>();
            weaponHook.CloseDamageCollider();
            gameObject.layer = 9;          // Set to player layer
            ignoredLayers    = ~(1 << 10); // Ignore layers 1 to 10
        }