Game Development Reference
In-Depth Information
//just remain idle
if(Random.Range(0,1000) < 1)
{
state = "patrol";
event = "enter";
currentNode = findClosestWP();
...
}
}
}
}
function Update()
{
//draw the paths in the scene view of the editor
//while playing
graph.debugDraw();
if(CanShootTarget())
{
prevState = state;
state = "attack";
}
else if(CanSeeTarget())
{
prevState = state;
state = "pursue";
}
else if(state != "patrol")
{
prevState = state;
state = "idle";
}
FSM();
}
Step 23. Play. If you can manage to outrun the NPC, you will find that it
goes into idle mode and then resumes its patrolling path.
5.6 Flocking
When you observe the movement of crowds or groups of animals their
motions appear aligned and coordinated; for example, a flock of birds flying
across the sky appears synchronized, staying together as a group, moving
toward a common goal, and yet not all following the exact same path.
Applying flocking principles to NPCs in a game can add extra realism to the
environment as secondary animations. If the game is set in a jungle setting,
having a flock of birds fly across the sky looks far better than random birds
flying in random directions.
Search Nedrilad ::




Custom Search