- Home /
What is wrong with this code?
Hi, sorry i keep asking questions but i'm a noob when it comes to this, anyway, i have an array of waypoints and i want it so when the enemy reaches the target waypoint then, it can only target the next one if it is active.
Here is the code( Pretty much the same as last time)
@script RequireComponent(NavMeshAgent);
@script AddComponentMenu("NavMesh/BasicMover");
private var Agent : NavMeshAgent;
var Target : Transform[];
var CurrentTarget = 0;
function Start () {
Agent = gameObject.GetComponent(NavMeshAgent);
}
function Update () {
Agent.SetDestination(Target[CurrentTarget].position);
if(transform.position.z == Target[CurrentTarget].position.z&&transform.position.x == Target[CurrentTarget].position.x)
CurrentTarget++;
}
Comment
Your answer
Follow this Question
Related Questions
Accessing boolean properties from array of transforms 1 Answer
Way Point Assignment 4 Answers
have array target person of most priority/stick with top prior 0 Answers
EditorGUILayout Array 1 Answer
move enemy to random transform array 2 Answers