Game Development Reference
In-Depth Information
private var seeRange = 10;
private var shootRange = 5;
private var keepDistance = 1;
private var heightOffset:float = 0.3;
function CreateBiPath(a: String, b: String)
{
...
}
function CanSeeTarget () : boolean
{
if (Vector3.Distance(transform.position,target.
position) > seeRange)
return false;
return true;
}
function CanShootTarget(): boolean
{
if(!CanSeeTarget()) return false;
if (Vector3.Distance(transform.position, target.
position) > shootRange)
return false;
return true;
}
function Start ()
{
...
}
function FSM()
{
var direction: Vector3;
var position: Vector3;
if(state == "patrol")
{
if(prevState != state)
{
graph.AStar(currentNode,goalLocation);
currentWP = 0;
this.animation.Play("run");
this.animation["run"].wrapMode = WrapMode.
Loop;
event = "update";
}
else if (event == "update")
{
...
}
else if (event == "exit")
{
Search Nedrilad ::




Custom Search