This is an old personal project from 2018, inspired by the Rollercoaster Tycoon games. It allows easy spline-based track creation with automated support generation and ride physics.
This is built in Unreal Engine 4.
It's no longer being worked on but might get revisited at some point in the future.
The track uses a spline-based system and supports all orientations. The rails are a spline mesh while any connectors and supports are static meshes. The ride can be altered in editor in realtime simply by changing the spline component.
A large challenge was that Unreal Engine 4's spline system doesn't support upside down rotations. Some quaternion math resolves this.
With the addition of a playercontroller and some UI elements, the track could be edited during runtime in just the same way.
Supports are generated based on track orientation, height and clipping avoidance. If a support would clip with anything it shouldn't it will attempt other forms or positions. If none work, the support is not generated. Each ride can specify values such as support spacing, height levels and track avoidance width.
Rail connectors for the track are placed based on an input distance. These also use mesh instancing to remain performance friendly.
Coasters are generated from a small set of meshes. Following images show sets of meshes used for 2 different coasters.
The system uses a datatable to store all info for every ride type.
To add a new ride you simply fill in all the variables.
An existing ride can be switched to a different ride type on the fly.
One issue was that the spline mesh does not precisely match the spline itself. This caused the static meshes to misalign. For this reason I needed a new "GetLocationAndRotation" function which matches UE4's standard spline vertex shader.
If I were to revisit this project I would continue working on:
- Wooden coaster layout support.
- Cart rigging.
- Special track pieces, e.g. pull chains, launchers, ...
- Player controller for runtime track editing.
- Implement other ride types, e.g. water rides, spinning carts, ...
- Proper meshes and materials.
- Adaptive track mesh selection based on curvature and length.
- MaxScript for easy track mesh generation and exporting.
- Track saving and loading.
- Per-ride build restrictions.