Hey there,
Got a question regarding best way to implement a game mechanic. Basically, I want a separate AI (think cat or dog) to follow the player around the world, keeping a set distance from the player at all times. If the player starts moving in a different direction, I would prefer that the AI stays where it is and wait for the player to pass them, rather than running ahead to get behind the player. I would also want to be able to issue a halt/follow command to the AI, so it won't always be following the player but might need to catch up.
The game would be top down, so both X and Y need to be considered.
So I had a play around in C2 trying to get this running. At first I thought I could maybe run a bullet behaviour off the AI with it set towards an angle of player.X with an offset to sit it behind. But I can see this wouldn't work if there was a solid between player and AI.
Pathfinding sounds like it might be the answer, but I have a few issues regarding this. All the documentation on pathfinding states that it's system intensive. As the AI is going to need to be continually changing paths to follow the player, I can see that this might be a real technical issue, especially if the player has more than one AI following. There also seems to be an issue where pathfinding doesn't work well in the every tick event, which I assume is because it has to find a path before moving along it.
So, what I'm thinking now, is maybe I need to set up the pathfinding for it to run every X seconds as a way of lowering system load, but I'm still concerned that this isn't the best way to do it. I've been searching for some resources on this this morning, but either my Google powers are running out, or this question hasn't been covered. There were a couple of projects I found that I thought might be good to look at, but all the download links were broken.
What's the best practise for AI -> player pathfinding then? Has someone successfully achieved this using C2 and, if so, is there a project I can check out that demonstrates it?
Cheers