This week I’ve been working on the first boss for Rhythm Station. I had this idea that I wanted the boss’ movement to exclusively use a grapple and pull mechanic to chase the player. These movements would be synchronized to the beat of the music. E.g. beat 1 - grapple, beat 2 - pull, beat 3 - grapple, etc. Here was my rough sketch of the idea:
I started out trying to implement this. Initially I tried using raycasts to dynamically find a short path to the player. This has the benefit of automatically handling changes to the environment. If an object is destroyed, the raycasts just won’t hit that object anymore.
While this did work in finding a path to the player, it proved to be too costly in practice, as I was experiencing freezing while the pathfinding was running.
I decided to try a different approach. Because the boss has a designated level, I thought I could just manually specify anchor points that the boss is allowed to use to move through the level. Here’s what all those points connected up looks like:
With this, I was able to run a graph algorithm (A*) over the points to find the shortest path to the player.
The last thing I needed to do for this method was to manually update the graph whenever an obstacle is destroyed. I just store a mapping between destructible objects and the anchor points they have. When an obstacle is destroyed, we find the relevant anchor points and remove them from the pathfinding graph.
Now I was able to implement some movements for the boss. What I have is still fairly crude and needs polish, but here’s a glimpse of the boss movement in action
Weston