Game Development Reference
In-Depth Information
if(dist < 0.5)
vavoid = vavoid + (this.transform.position -
gSpeed = gSpeed + go.GetComponent("flock").
vcentre = vcentre/groupSize;
speed = gSpeed/groupSize;
var direction = (vcentre + vavoid) — transform.
Step 10. Play. Take a close look at the birds' behavior. You will notice
they now dart out of the way in a similar movement to what is
observed in real flocking birds.
So far, the flocks created are reminiscent of crows or vultures circling in
the sky around their next meal. This could be used for a dramatic effect
in a game to point out the position of something sinister in the game
environment. More often than not, flocks used for ambience tend to be
traveling across the scene. To achieve this type of flocking, more rules can
be added.
Step 11. To make the birds move across an endless sky, we can add
a wind value. This is a vector indicating the direction of travel. Modify
the flock script to that in Listing 5.19 .
Listing 5.19 Directing Flock to Fly in a Set Direction
function ApplyRules()
var wind: Vector3 = new Vector3(1,0,1);
var dist: float;
var groupSize: int = 0;
for (var go : GameObject in gos)
Search Nedrilad ::

Custom Search