New Potentcial method for Trains to take on track curves!
Before I talk about an idea I had, I haven’t tested this idea (as I don’t know coding very well) however I thought it might be a good idea to share it and maybe get some feedback on it.
So right now we have two main methods of having a train go around a angled/curved piece of track. Those are either using a Spline (which is usually fast but can look unrealistic and also has less control on the track as you usually use just one spline for the whole thing), and the second is with physics (which right now is really taxing on UE4 and most computer systems). Both are usable but not always ideal.
I was talking to a friend of mine (who is a coder) and here’s what I came up with while talking to him.
We know that in real life that railways are not laid as one long and giant piece of track. I took this into consideration while brainstorming. We also know that in games modular design is heavy used in many games. So I thought that maybe making track laying more modular would be a good idea. But then you run into the issue of how you have the wheels follow each piece of track (both straight and curved) without having visual issues arise, as each track piece would be separate from one another.
Here’s where (I think) I solved that issue. We know that train trucks (the part of a trains wheel system that holds the wheels in place) follow the track based on the rails. So moving along straight track is pretty easy, but once a truck hits a curve you would run into possible issues with truck rotation. So how about instead of the truck looking at the track piece for rotation info/value, you have a dummy object do that instead. You just have the dummy object have the same rotation as the track, but the difference here is that you’d have a total of four dummy objects. One set for one direction and another set for the other direction (not sure if direction would change anything, but I feel like it might), then you place a dummy for each direction at each end of the modular track piece. In my idea this tells the train truck what the curvature of the track piece is and when it starts to curve and when it ends. Basically you are giving the truck only rotation values to keep it at the same angle to keep it following the rails properly throughout the piece of curve track.
Here is an image to better illustrate my idea. I only have track modeled, but you can probably image a train car following the track piece in your head.
The above image is the overall track piece (a curved one)
The next two images show the dummy objects (would be invisible in-game) at either end of the track piece. Keeping the idea of being modular in usage with laying track.
So that’s my idea. Like I said I haven’t tested it out, but I thought I’d share to see what others think. Maybe it would work, maybe not. But if it does then it may be the best way to get a track to look right (without being heavily demanding) and make it functional too.