How to make Dubins Paths in Unity with C# code

1. Introduction

In this tutorial you will learn how to make Dubins paths in Unity with C# code. This is how Wikipedia defines Dubins paths:

In geometry, the term Dubins path typically refers to the shortest curve that connects two points in the two-dimensional Euclidean plane (i.e. x-y plane) with a constraint on the curvature of the path and with prescribed initial and terminal tangents to the path, and an assumption that the vehicle traveling the path can only travel forward. If the vehicle can also travel in reverse, then the path follows the Reeds-Shepp curve.

But why would anyone need a Dubins path? One application is aircraft games. If you have an aircraft and want it to fly to a certain point with a certain direction, then the Dubins path will give you the waypoints.

But what if you have a car which can drive both forward and reverse? Then you will need the so-called Reeds-Shepp curves. I've made a self-driving car in Unity and I used Reeds-Shepp paths to improve the pathfinding algorithm Hybrid A*. The problem with Hybrid A* is that Hybrid A* doesn't care about the final orientation of the car, which is what Reeds-Shepp paths care about. This is how it looks like:

Self driving car using Reeds-Shepp paths

The white line is the forward Reeds-Shepp path and the gray line is the part of the path where the car is reversing. I will not write a tutorial on how to make Reeds-Shepp paths because the math is heavy, but you can download my code for free here: