Game Development Reference
In-Depth Information
function findClosestWP()
{
var gos : GameObject[];
gos = GameObject.FindGameObjectsWithTag("waypoint");
var closest:GameObject = gos[0];
for (var go : GameObject in gos)
{
if(Vector3.Distance (
closest.transform.position, this.transform.
position) >
Vector3.Distance (
go.transform.position,this.transform.
position))
{
closest = go;
}
}
return closest;
}
...
function FSM()
{
var direction: Vector3;
var position: Vector3;
if(state == "patrol")
{
if(prevState != state)
{
graph.AStar(currentNode,goalLocation);
graph.printPath();
currentWP = 0;
this.animation.Play("run");
this.animation["run"].wrapMode =
WrapMode.Loop;
event = "update";
prevState = state;
}
...
else if(state == "idle")
{
this.animation.Play("idle");
event = "update";
prevState = state;
if(event == "update")
{
Search Nedrilad ::




Custom Search