This page looks best with JavaScript enabled

Top Down Following Spaceship Controller

 ·   ·  ☕ 1 min read

Now that we have a spaceship controller that can take a direction input and turn that into movement we can start to play around with it. In this video lets demonstrate one of the really handy use cases I’ve found for this type of movement controller: basic AI.

Because our controller is designed to be able to turn a direction vector and convert it into thrust and rotation we can use that to track an object by subtracting the current position of our ship from the object we want it to follow. This creates a target trajectory that allows our ship to navigate towards an object even as it moves through space.

Most of what we are building here has more to do with how to make something interesting to follow. We’ll be doing that using Sin and Cosine waves to create figure eights and other oscillating patterns for our tracked object to follow.

Source Code for this series is available on GitHub:

The World of Zero Discord:

Sam Wronski
Sam Wronski
Maker of things, currently helping build cloud things @ Google. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!