January 2016
Intermediate to advanced
304 pages
6h 17m
English
Now that we have the function that can calculate the shortest path, we need to incorporate this behavior into the game.
We now need to make the enemies follow the vector of target locations that the pathfinding algorithm generates. We need the enemy to constantly follow this path, so we'll override its base classes' Update function, as it's called during every game's tick. The code that will do this is fairly simple; if there is a location in the vector, move towards it at a fixed pace. When the position is reached, we simply remove it from the vector. When the vector is empty, we know that the enemy has reached its goal.
We'll start by adding the function declaration to Enemy.h:
public: ...
Read now
Unlock full access