Train with multiple axles on a spline?

Hi!

Did anyone ever ask themself how we would get a spline-based train working with blueprints? Most trains have two or three axle per bogey and two bogeys per car. In UE4 I guess it would be best to have one axle powered and the others dragged behind along the spline (otherwise the distance between the components might get changed, I suppose).

&stc=1&d=1430068363

I would love to create some train or rollercoaster games but unless someone has a solution, we need a special component for this.

I haven’t tried anything like this before, but 's my suggestion. Can’t you literally just make a track like they have in real life, and just make a cart that fits onto the track? Maybe have some wheels on the bottom-inside of the cart that roll it along the track. I am not completely sure how the physics in UE4 work, but this should work just like in real life.

I tried that some months ago but the physics weren’t good/accurate enough for this to work. Especially not at higher speeds. That’s why I’d like to see a spline-based solution.

Well, not sure what to tell you then :frowning:

are some links that might help you:(The 3rd one should be the best)

If you are going for a spline based solution then you can ignore physics entirely and just animate it along the spline? I agree the physics doesn’t work well enough for this type of thing to be done completely realistically. I have been working on creating engines in game that work physically accurately, and while they can function “OK” I wouldn’t really use them in a proper game.

@Jamendxman3: Thanks. I should have mentioned that I know how to make something run along a spline. But your links gave me an idea I have to test when I have enough time.

@ZoltanJr: Think of a rollercoaster. The front wheels of the car are over the top point of a hill while the rear wheels are not. That’s where physics would come in handy. Just something that is locked to the spline and rolls physically correct forwards and backwards and can be dragged by another thing on the spline if connected to it.

is some interesting reading on the subject:

http://.learn-cocos2d.com/2012/07/starting-point-train-game-freeform-tracks/

If you just animate the front 1 along a spline based on the angle of the slope to change speed etc then you should be able to use physics constraints to attach the carriages to it and they will get pulled along. Figuring out the constraint to stop the train bouncing off the tracks would be an interesting 1 though.

1 Like

Well, physics are no option at all as you can see:

I recognize this is a older thread/topic, but I am actually trying to figure out the best way to get a train to function in UE4. Most people have used Splines, but a lot of the time the train looks terrible when following a spline and it looks like it’s derailing when it’s not.

There is however one person I have seen done it with physics (they confirmed this themselves). You can find a video of their work :

If you look in the video comments, someone asked what they are using and the uploader said Physics. How much would the frame rate be hit? It looks like the video uploader didn’t have really any frame rate loss. This same person was also able to get the train to smoothly follow a curve (or sort of a curve) in another video of theirs. See :

However they have not stated (yet) if they are using Blueprints or Hard Code. Is there anyone who can shed some light on how this is all done with just physics?

Thank you!

That’s impressive. I have no clue how that is possible.

Meanwhile I tried to make it look correctly again with splines:

However, somehow the simple calculations really slowed it down (as it moves the second bogey multiple times until it’s in a range that makes it’s position look acceptable) and I doubt it will run well enough with multiple cars, let alone multiple trains.

1 Like

Train physics it’s possible

Hey, I can confirm this and more i asked to him, including I was made ​​a simulation using a blender , because I do not have much knowledge about Unreal yet basically i used motor, hinge constraints how you can see

In next image can see the constraints

This image show the settings of railway

and a video

As you can see the model has some problems, probably because of parameters, the physical calculation at least on my PC required a lot of processing power which would justify the use of spline in most cases by this angle. But in this simulation I used real physics and if somebody wants the .blend file only need request it.

[MENTION=113028]Rafael PD[/MENTION]

I think the issue with your simulation is that no real rails ever curve that much in that short of an arc.

There are restraints of the track grade and curvature on the railroad to prevent from derailment, sliding backwards on steep grades, among other things.

Still, we need to get 401Sly to share with us his method, because his samples looks absolutely great. :smiley:

UE4 The Railway

UE4 The Railway

I saw some questions over bogie vehicles and tracking around curves there are limitations and am at present gradually refining the method.
is a short vid of bogie vehicle+train following track using BP physics only.

<iframe width=“640” height=“390” frameborder=“0” allowfullscreen></iframe>

Regards

PS if embed link doesn’t work could someone explain the embed process please.


You click this button and paste the link in (regular link, not embed) Looks like

Many Thanks for the embed info

@amigo I agree with you, the curve is not closed as I made, it’s necessary a space to the wheels not be locked.

@Sly401

Thanks for chiming in - could you please tell us more about what your goals are with this?

I wanted to do something similar for a long time, although my idea is to have an open-world train sim, basically a Fallout 4 of trains - go anywhere do anything. Sadly that goal seems way too lofty for one person, lol. :slight_smile:

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 '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.

'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 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.

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.