A downloadable tool

This train track generation tool was created as a hobby project over the course of three weeks to learn editor scripting for Unity. With this train track generation tool, it's easy to quickly create a train track mesh using Bezier curves in Unity.


For this project, I used the Odin Inspector plugin which is required for the package to compile.

The track is made by linking together multiple bezier curves. These curves can be easily manipulated with the handles.

The track is stored as an array of individual points. Each of the points has a reference to the points before and after it. Every point also contains the start position and start tangent that are used to calculate the Bezier curve. The references to the next points also contain the end positions and en tangents for the bezier curves originating from this point. This is done to allow for branching tracks where multiple curves are created from the same point.


The points can all be moved from within the scene view window using different handles. To allow for this I wrote a custom editor script that draws the following handles for the currently selected point:



For the unselected points, buttons are drawn for selecting, deleting, and branching to the point. A point can only be deleted if the track will still have 2 or more points left after deletion. A point can only be branched to if the point isn't already connected to two previous or two next points.




Download

Download
Train System.unitypackage 1 MB