[DEV] Bézier Spline Road Generation

This slideshow requires JavaScript.

This week I implemented a Bézier spline path generation tool in Unity to use for track generation. With this tool the user can, in real time; enable or disable looping (when enabled the last point is aligned with the first), set the width of the generated path, set the number of segments generated both along the length of the path as well as across the width of the path, and change the type of each point.

The three types of points available are the standard ones you’d find in any vector graphics image editing software: Free, Aligned, and Mirrored.


Free Bézier Point


Aligned Bézier Point


Mirrored Bézier Point

The free point has no restrictions on it, which can result in sharp, abrupt changes in your path. The second type shown, the aligned point, restricts the two handles to have the exact opposite directions of each other, but allows different lengths, resulting in smoother corners but still some flexibility. The mirrored type is like the aligned, except for that it requires that the handles to have the same length. This results in the smoothest corners of all three options, but it can be too restrictive for certain situations.

I must say thank you to Catlike Coding for putting together this great tutorial – it was a great resource for getting started on this topic.

The next steps will be aligning the direction of ships to the section of the track they are on and preventing them from falling off the edges.

-Andrew Weeks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s