Search Unity

Navmesh Tag

Discussion in 'Navigation' started by UnityBasic, Jan 6, 2015.

  1. UnityBasic

    UnityBasic

    Joined:
    Aug 9, 2013
    Posts:
    41
    I made a game with an enemy which follows you by the tag but not all enemies follow the character.
    If someone can improve the script i would be very thankfully.

    usingUnityEngine;
    usingSystem.Collections;

    publicclassEnemy : MonoBehaviour {

    publicTransformtarget;
    NavMeshAgentagent;

    //Usethisforinitialization
    voidStart () {
    agent = GetComponent<NavMeshAgent>();
    }

    //Updateiscalledonceperframe
    voidUpdate () {
    agent.SetDestination(GameObject.FindGameObjectWithTag("Player").transform.position);
    }
    }
     

    Attached Files:

    • Enemy.cs
      File size:
      374 bytes
      Views:
      925