I’ve started working on a roller coaster system for moving objects along tracks. I know that there are already a few solutions out there, but I think my approach is quite different.
First of all, it does not use splines. My goal was to create something that feels like RCT, where you snap different pieces of tracks together.
As I said, I don’t use splines, instead there are different Blueprints for different shapes of tracks. Each of these Track-BPs implements a different equation for the track curve. Currently there are
By snapping together these Track-BPs, you can create 3D curves with an exact mathematical representation. Of course, direction and radius of curvature will match automatically at the location where two tracks are snapped together. Tracks snap together automatically, when dragged into the level from the content browser.
The shape of a track can be modified by dragging the widget at the end of the track. This even works if the track is connected at both ends. Check it out:
The cart is another blueprint, it will find the first piece of tracks and snap to it. It does not use the UE4 physics system, but a simple set of equations to determine the speed.
Using this system, it is possible to create very comfortable roller coasters where the radius of curvature is not changing abruptly at the start/end of curves.
Here is an explanation of the different types of tracks used to make the roller coaster in the video:
How does it work internally? The cart is really driving on the tracks. This means that the Cart-BP knows which is the current Track-BP, and each frame it calls a function on the Track-BP to calculate the new cart position given the current cart speed. If the end of a track is reached, the Track-BP will return a reference to the new piece of track that is connected to the Cart-BP.