Permalink 02:40:49 am, Categories: Steering Behaviours  

In order to achieve better movements and steering behaviours from the entities I plan to make a Steering Property Class "pcsteer".
pcsteer will count of a set of properties and a set of functions, these two will blend to achieve more complex behaviours.

Some of the functions defined in pcsteer are:

Seek a target.

Flee from a target.

Pursue a moving target. This is different from seeking because it calculates the targets position in time T and, then, seeks it.

Wander This is done by randomly changing the entities direction between a given range.

Path FollowingThis will follow a sequence of Nodes. It can be used together with a pathfinding algorythm, ie: A*, to reach more complex targets.

Some of the properties are:
SeparationGiven a set of entities and a radius, a force would be created in order to flee from the center of mass of all the entities that are within the radius.

CohesionThis one works just like Separation but it will seek the center of mass of all the creatures that are outside the given radius.

Collision AvoidanceRight now pcmover checks if theres something between the entities and its target. If there is, it stops moving. Collision Avoidance will work like that, but instead of stoping it will add an evasive force to the entities movement.

How would a developer used all of the above?
Lets say we are this LOTR rip-off where three Trolls are trying to catch a Hobbit in the woods. There would be a bunch of trees we would like not to crash with, but besides from that there would not be any difficult spot to seek so we won´t need pathfinding.

Lets say we already created the entity and added pcsteer to it. We would need to define our steering properties:

* We define a weight for each force in our movement and a distance
* from which we will start avoiding obstacles
float weight = 2.0;
float distance = 7.0;
pcsteer[who]->collisionAvoidance(weight, distance);

* We define a radius for cohesion and separation so our trolls will
* work together without bouncing to each other
weight = 1.0;
float radius = 10.0;
pcsteer[who]->cohesion(weight, trolls, radius);

weight = 1.5;
radius = 5.0;
pcsteer[who]->separation(weight, trolls, radius);

//This have to be done for each troll in trolls

Now, we defined our static properties (they are not so static, we can change them whenever we want, but they will remain the same after any function call.
Now we would probably want to define a basic behaviour, lets say we want the Troll to wander through the woods until he sees the Hobbit:

trollBehaviour(int who){
//its more important not to crash than catching the hobbit
float weight = 1.0;
float radius = 5.0;
float offset = 3.0;
pcsteer[who]->pursue(weight, hobit);
} else {
pcsteer[who]->wander(weight, radius, offset);

As you can see we don´t have to worried for collisions, separation or cohesion while defining our behaviour because thats already defined during the creation of the npc. The idea is to have more complex behaviours too like formations, flocking and swarming, but I will add that later.

The only thing left for me to explain is the radius and the offset in wanders call. This is because the wander function I have in mind uses an invisible circle in front of the npc to calculate its new direction. offset is the distance between the entity and the circles center.

Trackback address for this post:

This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

Comments, Trackbacks, Pingbacks:

I couldn't refrain from commenting. Very well written!
PermalinkPermalink 2013-01-09 @ 06:20

Comments are not allowed from anonymous visitors.

October 2017
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          




XML Feeds

What is this?

powered by