There are a lot of algorithms out there for making something follow a path. I should know, I’ve posted a couple. The thing is, a lot of times I find myself following a path just fine, but trying to make that path smooth is pretty frustrating. Some methods might take too long to execute, or don’t really work in realtime, or are just waaay too beefy for what I’m trying to do. So, I found a pretty simple algorithm for your Game-Dev-On-The-Go to help you find the way.
Alright, here’s the setting:
You have an enemy, he’s flying in space. He flies a basic patrol that selects a random path from a collection of waypoints. You generate your path, and it returns a List of Vector3s. Watching your enemy fly a path filled with extreme <90 degree turns looks dumb. Real dumb. You start to consider taking a job in construction, but wait; there's a simple solution: what if you could just cut out those sharp corners?
Well, that's when we call in Chaikin. Continue reading