Train with multiple axles on a spline?

Hiya

A neat idea, but I can forsee a couple of problem area’s

Railway track is very rarely constant radius, the transition is invariably a bezier curve, it might not be a problem depending on what you are after in the final product.

You could set bogie rotation via this method ( although the transitions would need some refining) but you also need to calculate the lateral offset.
The centre of the bogie is not over the centre line of the curve (again it is probably fine with a short wheelbase and genorous curves )

So far all rail related simulations (as far as I know) do calculate that the bogie centre is on the centre line (spline) if you introduce the offset it makes calculating the position of the second bogie horrendous.
This was far beyond the scope of my simple mathematics, hence I have explored the physics option.

Only my thoughts but hope of some value

Paul_G

For the most part I followed this. Some of it I didn’t. Can you explain what you mean by lateral offset?

's some information that might help a bit with elaborating more on my idea. Both wheel trucks would look at the dummy object, that way both have the same rotation value. Also I know that not all curves stay at the same angle, but that would be fixed with the modular track idea. You would have a selection of track pieces (all based on realistic radius’s/angles) that you can then piece together to get what you want. It would allow far more customization depending on what you need for your game map.

For most transition problems, you could just set some sort of smoothing to the transition between rail pieces (probably based on the distance between the dummy objects for each piece of track), that way the wheel trucks should transition smoothly between a straight piece to a curve piece to another curve (or straight piece).

And I think as long as the dummy objects can be used, the wheel trucks shouldn’t have issues with taking a curve and still looking believable. As they are looking at a rotation value that would continue through the curved piece of track and as long as the train can follow along the track (and not just a single axis), then I feel like this idea/method would be a good alternative.

Hiya

The Lateral offset I was referring to is best described as…

Front axle of the truck (bogie) is central of the track centre, so is the rear
Therefore the centre of truck is somewhere along the line between the two points, which is a chord across the curve described by the track centre line.
This can be calculated… it is something like the cosine of the axle slip angle *2 / half the tuck WB
where the slip angle is the difference between the angle of an axle and the perpendicular at that point in the track.

As I mentioned it may or may not be a problem with short WB trucks but a ten wheeler will be quite a long way out

The angle of the trucks is not always the same… they are only the same if they are both on the same constant radius section
Probably best illustrated when one truck is on a right hand curve the on a left … as is the case of a crossover in the track

Nothing wrong with using set track sections, I am doing exactly the same with my projects for the turnouts but they are transitional curves (bezier)

If I have this right you are triggering a truck rotation every time a curve changes direction / radius, don’t forget that track can change in the x and y (roll and pitch) as well

Best of luck with the project, I couldnt get calculated position to do what I needed.

Cheers

Paul G

Well with the roll and pitch could also be changed based on the dummy object. You’d just have to rotate them the right/correct way. In the end, there may be a lot of modular track pieces, but this would also lead to the (I feel) best amount of customization.

Like I said still an idea, but hopefully it might be another way to get a train functioning in a realistic manner. At least someday.

I forgot to ask in regards to this post. Are you using a Spline based rail system? Or 100% Physics? I think you said later on that you use transitional curves (bezier), can you expand on this? It it more efficient then using UE4 Spline drawn track? Also are the bezier curves created in engine? Or in a external modeling program?

hiya

the answer is both… it uses 100% physics but the tracks are created with a spline.
The turnouts have bezier curves (transitional) that are created in 3DS max.

As regards efficiency I actually have no idea, it was not the primary consideration.
The target was simplicty of implementation to produce a good (read acceptable) representation on harware that was available.
Efficiency and optimization will come later should the project progress that far.

The whole thinking of my experiments were that if in you avareage shooter you drive your Humvee/ jeep/ tank between two buildings… the buildings will guide the vehicle through the gap via collisions.
Refine this and create a collision model that is simple yet produces an accurate and consistent result.
Not the way its normally done but I like being different :slight_smile:

Paul G

Just saw the news announcement for Trains Simulator World. Which is apparently made in UE4.
See :
https://www.youtube.com/watch?v=5ChAhllHOAI

So any information on their development process for how they handle train movement, physics and so on?

All you need to do to calculate the position for each axle is to use a percent value 0 to 1 to control the distance along the spline from point to point.
Edit actually this won’t work entirely if the spline points are further or shorter apart, only if the distances are equal. Hmm, interesting problem.

Edit2 : Just placing the axles at the correct distance apart and moving them at the same speed will keep them at their correct position. If the carriage is attached to both the axles by a physics ball joint component each in 1 axis you will get realistic axle rotation under the carriage. could limit the rotation in a second axis to get the up and down rotation from going up and down.

And to apply physics, toggle it on and off, I don’t think even the simulation train games are physically modeling a axle wheel / rail system to propel itself. Maybe but i highly doubt it.

Hi Paul, so in general you would push your train through an invisible tunnel, is that the basic idea?

Thats one idea, and could work but using any method of Physical restraint will take days/ weeks/ months of trial and error to get something to behave realistically…

My own project has and is still being adapted / tuned to get an ever increasing speed range for consistent behaviour ( I’m up to 50 mph ish ATM)

Try thinking Slot car

Good Luck with your project

Paul G

Your videos look awesome, so much attention to detail.

In the “slot car” analogy, would the “pin” be guided by the “slot” in the track by actual physics or following the spline (i.e. get location / rotation along the spline)?

old thread but always interesting topic. I also need tracks (rail). From where you got those rails which you implemented in your level ?

Hmm so even if we do adjust the spline point curves, the train wheels will still derail all off the track and fall down like Big Riggs Off The Road Racing. A pity I thought adding in more spline points would fix that, but I do remember years ago when attempting this as well with the Keyframe system in the Red Engine (old game engine) we had to use the standard
moving keyframe to move the train as well as to use a rotating keyframe to get the train to rotate slowly around the bend of the track as its moving.

I wanted to do a game map in Unreal Engine with some coal carts that go around a couple of 8 figure tracks. So that might be more tricky because it has more than 1 bend in that type of track. So I need to get that system to try to work. So can I get ahold of that little demo of your Train cart to have a play around with the mover spline system that it uses? Because I don’t yet have a tutorial on how to set up the mover spline system for doing moving small coal carts to get them moving along train tracks.

But I think trying to do it with the physics on in the engine may involve too many other variables to cause the wheels to want to always fall off. You could
also add in more or less KG MASS also to the cart and see what happens to it if using physics, it might cause it to stay more firmly on the tracks or not. So I think to get the cart to turn the wheels on the track without it falling you might need to animate the cart turning slowly all around on the track in an animation program.

But I do remember way back in the days of Red Engine, we used a Keyframe pulley system for moving and rotating things. So for this sort of thing to get a cart to travel and turn around bends, we had to add in all the keyframes first for the whole entire route of the track, the cart would travel along then go back and add in rotation keyframes at each bend with a time delay to tell the cart how quickly to turn around the track.

After using this system, which I find quite unflexible in terms of train configurations, I ended up creating my own system from scratch with all that I’ve learned since I’ve created this topic. It works quite good so far:

https://.youtube.com/watch?v=iifU7Nxtpdk
(please excuse the shoddy camera work)

The train is set up in levels which determine the order in which they are updated:

Each frame an actor in the world, called the “TrainManager”, takes all wheel references from it’s pre-runtime constructed array and calls a function in the wheels to advance on the spline relative to their speed and direction. Afterwards the other levels of the train are positioned according to the position of their children/previous levels. That’s basically it.

This also means your wheels will move out of the bogie if you change a switch while one of the two axles has passed it. So far there are no functions for locking switches, adding cars (this test train is one unit) or looking ahead of the train to avoid collisions or recognize signals.

It’s WIP and currently I’m working on something else but even if I was working on it, I don’t intend to share it, as I made it for my own game’s requirements. But maybe this little insight helps some of you getting your own trains running.

Okay, So the Railway System that Sly401 has been working on is very intense. In Fact I’m still trying to get help building a prototypical steam locomotive for UE4 so I can start my own Railway Simulator.

Been a while since I visited this thread. I hope there’s something that the community can use by now.

That switch system is actually something very close to what I am hoping to find in a train setup. Just that the difference would be that it can be changed with a mouse click, or by a character model that the player would control (exiting the cab of a locomotive) and then throwing a switch mechinism. Sadly I saw that you won’t be sharing the system at all, so there goes that hope that I’d be able to somehow obtain what you’ve created.

It’s a real shame that there’s no good user created systems that you can find for UE4, even this many years after the engines public release. Pretty bummed.

Not sure if any of the UE4 Devs will ever see this, but if any of you do. Could someone on the team please create a system to use when wanting to create railway systems in the UE4 engine? At this point I sadly cannot hope to see someone in the community do something like this, and I am not a very coding geared person (tried to be, but don’t have the right brain for it). So I doubt I’d even know where to start with any of this.

Forgot to ask in my last post, but did you use Blueprint for this? Or were you using written code?

I would imagine the game might be finished by now ? was it released?

yeah, I’m trying to do this as well, using blueprints, but it’s hard to know where to start

this looks like a good hit though , although I would have a question, does that mean that the train was 1 skinned asset ? or wheel, bogey and train were all separate ?
https://forums.unrealengine.com/filedata/fetch?photoid=1361824&fbclid=IwAR1BEe7t-QD3Xi_m10WlhBqdXKUxmmU-x3Vj0LOQWAfvnQlvP0i9Dk7noNk

Does anyone know a solution to the spline joining problem?

If the train is moving on 1 spline everything is fine, it’s worse when it has to switch to another spline.