I started with just making the following objects the child of the parent object and this expectedly did not give the right results. The movement felt stuttery and there was a lot of lag. So I first started by writing a simple follow method which worked fine for the required needs. However, I had to evolve this further to incorporate system where the children would have to go to the food store, fill up their hunger stat and return back. Using my single agent implementation I was able to successfully replicate this implementation up until the point where the child would follow it’s parent and refill their stat – but I was not having it go back to the parent.
This is where I implemented a basic state machine where I used bool-based toggles to implement the mechanism where I switched the “follow” state off when the agent was hungry and once the stat was full, the “follow” state was switched back on.
My algorithm for the group following mechanism was made using a reference to the two child objects and establishing a buffer distance so as to not make the movement “sticky.” The agent either followed it’s forward vector and only changed it’s heading if the parent moved a certain distance from the child. This gave the following behavior I expected and the following snippet further explains my implementation.
This exploration was a primitive proof of concept which will be later used for my senior project game where the code will be much cleaner than