top of page

Curved Path Tool

Looking to expand upon my experimentation with tools and editor extensions I added control handles to position the path nodes in my space rail shooter from my previous posts. I then decided to additionally add bezier curve support as I'd never actually done any bezier spline work before and was curious about the maths involved.

With a little bit of google research and some consultation with my workmate Finn Morgan I was able to get the math side of things handled and get into implementation. This project did present a few different issues. The first was due to the nature of how the custom inspectors pass values back and forth and the way I needed to handle values within my equation I had some trouble with whether I should represent the control points using structs (value types) or classes (reference types). I ended up settling on structs as it required less refactoring and made the methods for my equations more straight forward but it did mean my custom inspector code was a little more convoluted than I perhaps would have liked.

I then implemented custom handles which can control the position of the control nodes and the gizmos to draw the path.

Really all this does is take the short main nodes list from the designer, give each of those one or two control nodes (depending on where they are in the path, start and end only need one), then project a number of additional nodes in-between each based on the position of the control nodes, and use that as the actual route for the AI/Player/Object/Ect within the game.

I also had a problem at one point with my misunderstanding of the equation which resulted in some crazy results, essentially I had the nodes in the wrong sequence in the equation, this didn't stump me for long but made for some crazy results.

The end result working with my game AI:

Featured Posts
Recent Posts
Search By Tags
No tags yet.
Follow Us
  • Facebook Classic
  • Twitter Classic
  • Google Classic
bottom of page