Game Development Reference
In-Depth Information
{
currentWP++;
}
//if we are not at the end of the path
if(currentWP < graph.getPathLength())
{
//keep on movin'
var direction =
graph. getPathPoint(currentWP).transform.
position —
transform.position;
transform.rotation =
Quaternion.Slerp(transform.
rotation,
Quaternion.
LookRotation(direction), rotationSpeed * Time.deltaTime);
transform.Translate(0, 0,
Time.deltaTime * speed);
}
}
else if (event == "exit")
{
}
}
else if(state == "idle")
{
this.animation.Play("idle");
event = "update";
if(event == "update")
{
//just remain idle most of the time
if(Random.Range(0,1000) < 1)
{
state = "patrol";
event = "enter";
if(currentNode ==
GameObject.Find("Sphere17"))
goalLocation =
GameObject.
Find("Sphere2");
else
goalLocation =
GameObject.
Find("Sphere17");
}
}
}
Search Nedrilad ::




Custom Search