Advertisement

Follow target behaviour tree

Started by March 20, 2011 06:56 PM
3 comments, last by Ashaman73 13 years, 10 months ago
Hi.

Now I'm trying to add behaviour trees into my project. Today I've finished implementing simple movement and started the "FollowEntity" behaviour.

It's algorithm is:

1. Actor receives "Follow" order and target entity.

2. Actor's DesiredDestination is set from the position of the target (for simple movement DesiredDestination is set from input).

3. "MoveTo" behaviour is executed which is Sequence of 2 Actions - "FindPath" and "FollowPath"

4. If target entity starts moving, we should update DesiredDestination at some frequency and re-run step 3 from the beginning.

5. If we reached the target (distance < threshold), actor should stop and optionally face it.

6. If target is lost behaviour fails and decision maker chooses other one to execute.

Can anyone explain me how to construct tree that implements this algorithm? Steps 1-3 are easy but I'm not so familiar with tech yet to understand how to make tree do steps 4-6.




Also I have few points to discuss about BT data storage and Action->Action communications through Actor variables. Need I to start a new thread or it will be normal to ask here?

Thanks in advance.
Sounds to me like you don't really need a BT here, but rather a leaf of your BT should invoke a steering system that handles the following process.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Advertisement
I try to avoid code duplication if possible. Since I already have FindPath and FollowPath actions I want to reuse them.

Hi.

Now I'm trying to add behaviour trees into my project. Today I've finished implementing simple movement and started the "FollowEntity" behaviour.

It's algorithm is:

1. Actor receives "Follow" order and target entity.

2. Actor's DesiredDestination is set from the position of the target (for simple movement DesiredDestination is set from input).

3. "MoveTo" behaviour is executed which is Sequence of 2 Actions - "FindPath" and "FollowPath"

4. If target entity starts moving, we should update DesiredDestination at some frequency and re-run step 3 from the beginning.

5. If we reached the target (distance < threshold), actor should stop and optionally face it.

6. If target is lost behaviour fails and decision maker chooses other one to execute.

Can anyone explain me how to construct tree that implements this algorithm? Steps 1-3 are easy but I'm not so familiar with tech yet to understand how to make tree do steps 4-6.




Also I have few points to discuss about BT data storage and Action->Action communications through Actor variables. Need I to start a new thread or it will be normal to ask here?

Thanks in advance.


Well, basicly you should have something like this for static targets:


- move_to_order(sequence)
* set target from order
* move_to_target(sequence)
= find path to target
= action: follow path
= action: direct move to target (dist<threshold)
= action: face target


This is just a bloated version of a BT, you can combine many nodes into a single node/action, which is, as Apoch already said, more desireable in your situation. Following a moving target is more or less single complex action and you should not try to press this into a BT form. You should have something like this:

- follow_order(sequence)
* set target from order
* follow_action

The follow action succeed once it reached its target or fails if the target is out of range.
Wanted to add that I use three basic movement actions in my BTs:
- move_along_path ( move along precalculated path)
- move_to (move to target, directly or calclulates a path if necessary)
- follow_and_act (follows a target and executes externally controlled actions).

The last action is the most complex one. It follows a target until it is inside a certain action range and in visible contact. Additional the BT can update the running action by setting desired action to be performed while this follow_and_act action is running. This way an entity can follow its target and i.e. attack it with close or range combat attacks.

This topic is closed to new replies.

Advertisement