Dynamic Pathfinding - Terasology/TutorialPathfinding GitHub Wiki
Flaws in Static Pathfinding
Up until now, we have implemented static pathfinding. We first compute the path, and then after the path is computed, we walk along the path to reach the destination. This performs well in the case of static objects such as wells, or trees. What if the target kept moving, then we would end up in the wrong place. For use cases such as following a moving target, we have Dynamic pathfinding. The behavior file looks something like this.
{
sequence: [
{
set_speed : {
speedMultiplier: 0.4
}
},
{
loop: {
child: {
sequence: [
set_target_to_followed_entity,
find_path,
setup_continuous_pathfinding,
{
timeout: {
time: 3,
child: {
move_along_path_continuous: {
child: {
move_to: {}
}
}
}
}
}
]
}
}
}
]
}
The setup_continuous_pathfinding node is essential for characters following a moving object. This allows for the path to be interrupted and for the revision of path calculation.