示例#1
0
    // Update is called once per frame
    virtual public bool Update()
    {
        //other part of my old movement

        //finds the player position and makes the enemy face it
        //unlike the mouse pointer the enemy and player will be at the same height
        //so it doesnt need to be adjusted
        //   transform.LookAt(thePlayer.transform.position);

        //Changed my original movement method to one that uses pathfinding
        nmAgent.SetDestination(thePlayer.transform.position);

        //Checks if the Time freeze is being used
        //This needs to be seperate from the update for BossEnemy's shield to work
        Freeze();

        // Health/Death tracker
        if (currentHealth <= 0)
        {
            //Tells the player what deathSound to play
            //Restores some of the players health
            //Kills the enemy
            //Updates the active enemies
            thePlayer.playSound(enemyType);
            playerHealth.RestoreHealth();
            Destroy(gameObject);
            theTracker.RemoveEnemy();
        }
        return(true);
    }