Now that I have modelled, textured, animated and implemented the ant in game I was noticing a large amount of clipping through the terrain because the animations are very static to a flat surface. So to rectify this I needed to implement a “simple” inverse kinematic script to control the individual limbs during the animation.
The process itself is quite simple taking the limbs placement during the frame of the animation and calculating its relative position to the ideal ground then works out where the ground actually is and adjusts the limb accordingly.
In theory this is quite a simple task but I had a world of headaches when it came to scale of the ant as the way that the script takes control of the limb can cause problems if the scales are not set to 1. The results were crazy and I had the ants limbs flailing around at all angles until eventually the scale of the limb grew too big to be seen. It was a challenging process to troubleshoot but once I had done enough research into the issue I was able to make the required changes to get it working.
And now as you can see below the ant trots along quite nicely.