Пример #1
0
    // called instead of Start() due to prefab Cloning/Reusing
    protected override void Initialize()
    {
        // Just Assigning refrences
        spawnManager = FindObjectOfType <SpawnManager>();
        agent        = GetComponent <NavMeshAgent>();
        fire         = GetComponent <FireSource>();
        zombie_audio = GetComponent <AudioSource>();
        anim         = GetComponentInChildren <Animator>();
        hitbox       = gameObject.GetComponent <CapsuleCollider>();
        fireHitbox   = fire.GetComponent <CapsuleCollider>();

        // Health and Speed defined on Prefab in editor
        setHealth(MAX_HEALTH);
        agent.speed = SPEED;

        // set dafault bool values
        dead            = false;
        isAttacking     = false;
        hasDealtDamage  = false;
        fire.isBurning  = false;
        agent.isStopped = false;

        // Assign torch object reference array
        torches = spawnManager.torches;

        // Send Navmesh Agent on its merry way to the closest torch
        target = FindTarget();
        SetDestination();

        // May not be necessary: resets AC upon spawn
        if (!anim.isInitialized)
        {
            anim.Rebind();
        }
    }