Polarith AI

front-end / back-end: AIMFollow | Follow
inherits from: AIMSteeringBehaviour | SteeringBehaviour

The moment might come where an agent needs to focus on a single target. For instance, it needs to follow one waypoint after another, such waypoints might belong to a path (possibly found by an external global decision maker). The generated objective magnitude is dependent only on the MagnitudeMultiplier. For this behaviour, the distance to the target Target is not relevant at all.


This component has got the following specific properties.

Property Description
Target If this is specified, then the position of the specified game object is used and TargetPosition is ignored.
TargetPosition If Target is not specified, this value is used to set the agent´s target manually.



By setting the Target or TargetPosition properly, this behaviour can be combined with external pathfinding algorithms.

Depending on how your pathfinding works in detail, usually, there is the moment where your pathfinding algorithm is done with its computations. Then, you have got your computed path your agent should move along. Such a path normally consists of several different parts (linear line segments). The corners between these lines is what we call waypoints. Now, you want your agent to follow these waypoints one after another, and every waypoint has got a position in the world. These positions you can put into the Follow behaviour. You may use an empty game object to indicate where a waypoint is. So you just need to adapt the object position as you like. For example, you build a simple script which detects if your character reached a certain waypoint, and if it has, you can put the game object to the next waypoint to be followed. Another and more elegant option would be to directly hand over the vector position to the Follow behaviour via scripting. In the case that your pathfinding results in spline curves (perfectly round), things get more complicated. Therefore, we plan to write another behaviour in the future to handle such path types as comfortable as linear paths, too.