[OPEN-SOURCE] Machinery Modelling Toolkit

I don’t know if this has been asked, but will Trains (Steam or Diesel Locomotives) be added to this? I think this would be an awesome thing to add to a plugin like this. Considering that trains are non-wheel based (at least car/road wise), I think they would be a great option to add.
There is one video on the web that I have found that the user has done an incredible job making. You can find it here: UE4 The Railway - Basics-1 - YouTube

I have noticed that a lot of UE4 users just go and use a single Spline and have the train follow it. However this create unrealistic movement and the wheels of the train look absolutely terrible (meaning they always go around corners and just clip through the rail). This give the train a verystiff and rigid look, adding to a unrealistic feel of the game.

My message to the Original Poster,
Do you think you could add a functionality that can be seen in the video I posted? Or would it require an entire separate plugin on its own? It’s obviously possible to make a Train look and move correctly, but the common user is having trouble with this (you can find a multitude of examples where people just use Splines for the train track and then just tell the train to follow the track). I think having someone who already knows how to implement non-wheel/road based vehicles into UE4 would be the best bet to making Trains look and function on a higher level of realism.

1 Like

Honestly, I have zero knowledge of the train physics. The video does look cool and I’m curious how interaction of the wheels with rails is calculated. Driving along the spline approach is very convenient from the game play point of view, unless you are building a real train simulator. I wouldn’t be surprised if with a proper simulation of the wheel / rail interaction you would have to build rather realistic tracks for trains to actually work. Which can place quite a heavy limit on your level design.

1 Like

Working on adding my tank and I’m at the part where I need to make my own custom splines for the tracks, however, following the tutorial I just can’t wrap my head around it. It seems like a rather big design flaw that you can’t edit splines in the BP Viewport but only in the actual PIE viewport. So I can’t seem to find a way to get the positions of the spline points from the PIE view to the actual BP.

How did you go about setting the tracks up for your M113? If I try and use the sliders, UE4 will freeze for 10-20 seconds which makes it absolutely impossible to use the sliders for smooth and accurate transitions. So I have to enter numbers over and over and just play the guessing game.

Maybe this helps:

Otherwise I’ve just added a box component, then allign it with wheels where spline control point should be and copy coordinates into array, move box to the next point and repeat. With tangents this doesn’t work and you have to tweak them manually.

Aye, just after posting that reply I figured out how to do it. Resizing the boxes to a size of 0.2 helps as you can easily align it to the middle of your wheels, after that it was a pretty straight forward procedure, especially due to the fact the other side is simply mirrored but with a different Y coordinate.

The tangents, however, would’ve been a massive pain. Luckily, removing the default ones ended up with somewhat decent results.

Here’s a little quick preview of my first test;
https://streamable.com/qtd7

I’m getting there, but there’s some weird stuff going on and I quite frankly am rather clueless as of now. As you can see, it doesn’t really like driving over stuff and easily gets stuck. I have absolutely no idea what’s going on with some of the wheels on the right-hand side as they’re clipping into eachother in some rather odd fashion.

How important is it that collisions are accurate? I followed a similar scheme you used for the M113, the road wheels have a fairly detailed cylinder and the sprockets have octagon-like shape instead. The collision for the hull’s something I threw together rather fast, but it shouldn’t be colliding with the wheels. Also, as for the suspension, can I place them a bit as I please*(both in terms of height and offset from middle)*?

Will continue to fiddle a bit with it and then I’ll move on to adding the turret and barrel.

Edit:

Oh and forgot to mention, I did not make that model. It was available as a free download on a website and was fairly detailed and nicely modeled. Wheels however aren’t accurate it seems.

Can you enable debug mod and take a screenshot in it? So I can see where contact points are generated. Looking at the track on the right side, I think there is issue with the spline and perhaps in how road wheels are connected to suspension. Clearance on the tank looks too low to me, it might be getting stuck on things because of the main body collision.

As far as I remember you don’t need any collision on road wheels, but it’s fine if you have collision meshes, collision itself is disabled on them anyway.
Road wheels are aligned with suspension on every frame, so you can move suspension where you want and wheel will follow, if wheels get misaligned when you do this, you have to change their pivot location in modelling package and re-import.
Vertically you can place suspension higher or lower but don’t forget to adjust its stiffness to get proper clearance.
Regarding wheel and suspension position we had discussion here:

I managed to figure out what was wrong, in RegisterSuspensionHandles I hadn’t ordered the wheels properly*(R07, R06, R08 instead of R06, R07, R08)* I added since UE4’s component list is a pain when it comes to organization. But it was a simple solution and it’s working fairly well now. I tweaked the collision for the hull a bit and raised it a little and it’s far better now. Still some issues with the sprocket colliding with things first and thus it tends to get knocked left or right pretty wildly*(maybe something increased mass will help fix?)*.

I’ve temporarily added the turret, will be trying to figure out how to go about making it so the turret pawn*(atm it’s just a separate actor)* is attached to the hull pawn, but can still move about. So got some research to do on how that stuff works. After that I’ll see how network replication works for some initial testing on that. :rolleyes:

But so far it’s coming along pretty nicely, I was surprised at how well the Tiger’s weird suspension worked with your system. I have yet to tweak lots of settings such as suspension stiffness, engine curves and all that.

Glad you have found source of the issue!

Regarding mass - go with the real mass and make engine “stronger”, there is Engine Extra Power Ratio variable at the bottom of the list, try setting it to 10 and higher if there is not enough power.

Check if sprocket has a different physics material. As far as I remember, on M113 I’ve used low friction low restitution material so it would rather slide over the obstacle than bounce back. In new version of the tanks, sprocket and idler will work just as normal part of the track, so tank could scale high obstacles.

I would add turret as a static mesh component and attach it chassis using physics constraint. To turn it you can use physics too, so allow it to yaw and add angular drive which will keep some default direction. Later when you want to steer it, just set a different angular target for the angular drive of physics constraint that hold turret and it will do the rest. There is example of exactly this approach in steering of the front ski on Aerosled.

I don’t think adding/programming trains would be any worse then a tank. Considering that a train can only go where the tracks are laid, they shouldn’t cause too much issue with the level design. And I don’t think they would have to be at the level of simulator (like Train Simulator is), but I feel like they can be better then what they are right now. Pretty much either nothing at all, or completely unrealistic. Beyond the video I linked, everything else that I’ve seen related to getting a train into a level just looks…gag worthy. Most people seem to have the train follow a Spline object, that then has a train track mesh attached to the Spline. This looks okay on a straight section of track, but as soon as any part of the train hits a curve section, it is completely obvious that it’s a poorly designed system. Meaning the wheels of the locomotive don’t stay on the track, so half the wheels are either semi-on the track, and the other half are not on the track at all.

I don’t know how UE4 works when it comes to having a object follow a Spline, but it looked like (in the video(s) I’ve seen) UE4 has the object follow the Spline based on the objects pivot point. So this looks semi-okay with cars, road based, and other wheeled based vehicles, but because of how trains are built, it looks atrocious. Completely breaking the suspension of disbelief.

I think the level of performance required on the level or engine can be either heavy or medium. If you are thinking in the terms of simulator, sure it can be demanding but that’s because the train would be the games focal point. But if someone can find a in-between where you can still have a train (that looks more realistic then what we have now), but still have other game play focus. Red Dead Redemption had a more functional train then what we have now, and that game was on a (now) older generation console. Though UE4 is built best for running PC hardware, so I have a feeling that getting a train that functions and looks better then RDR, but still doesn’t have high demand on the system is doable.

I am a big train (both real and model/hobby based) fan. So I have a pretty good knowledge of train things. Really it comes down to whether the user of UE4 wants to make a single non-articulated locomotive or a articulated locomotive. Union Pacific (based in the USA) has some pretty darn good examples of both articulated locomotives (Like the 3900 class Challenger and the 4000 class “Big Boy”) and non-articulated locomotives (plenty of good examples, so too many to list). I would recommend looking there if you want to get a better idea of how locomotives work (mainly Steam though).

I think getting Steam locomotives would be the hardest to get looking somewhat realistic. As they can have a variety of wheel configurations. Though I think this can be overcome with some sort of Blueprint Template system that can be edited (maybe with a sort of wheel number node base). Maybe having a set of Blueprint nodes that are based on each wheel set (meaning a node for wheel trucks with a total of two wheels, or one for three wheels, and so on). This would allow not only realistic based locomotives, but also for non-realistic ones (more fantasy based). Then you would connect all the Blueprint nodes together and then they would go into a “Input” of a node, maybe just called “Locomotive”.

I hope this hasn’t been confusing. I tried to explain my idea the best I could. I am not much of a coder, so I don’t know the best way to get this implemented. Though I think I will do a quick (and rough) diagram of what I am thinking up in my head. I will post it later.

Again though, I don’t think we need trains to be at the level of simulator but something better then what we have now would be great.

Okay, so as a addition to my last post, here is the image I said I would make. It’s very rough (no fancy art stuff here. Lol), but I think is conveys what my idea is pretty well. Please let me know if there is any confusion.

Also when a locomotives wheel configuration is listed, it takes into consideration both sides of the locomotive. So instead of there being 4 wheels (meaning just one side of the locomotive) you have 8 wheels. Some goes for any other wheels on the locomotive (both Steam and Diesel). This is because when you take the wheels off of a locomotive, you would be able to see a metal rod that connects the two single wheels into one piece. So basically when finding the wheel configuration of a locomotive you look at both side of the machine.

Playing around with the performance of my Tiger tank at the moment, but I’m getting some weird results when fiddling with gear ratios and the final drive. It’ll cycle through all but the 7th and 8th gear super fast.

Here’s the data I’m currently using*(click for larger screenshot)*;
http://i.imgur.com/1dQFbd3m.png

I pulled these values from this website. It’s possible that I’m not setting this up properly, I looked at the settings for the M113 and saw that the 1st gear has a ratio of 0.0. I’m not entirely sure in what order these gear ratios are set up, so I assumed that 0 means first gear - or is it reverse?

Would it be possible to add more than one reverse gear using this? The Tiger has 8 forward and 4 reverse. Also the start of the torque curve refers to the idle RPM, correct? :slight_smile:

Edit:

I forgot to change the hull’s mass, after doing that it is a little bit better - certainly does feel heavier. Though it still speeds through the gears 1 through 5 a bit too fast I do believe.

Edit2:

I just went into War Thunder real fast and test drove the Tiger H1 under Simulator settings, and it does indeed seem to switch almost immediately to the 5th/6th gear on flat terrain. So I guess it’s working like intended. :rolleyes:

How would you align wheels with rails? I know that some of the train wheels are installed on bogies which can rotate independently from the rest of the train. Doing this alignment with physics might be a bit too challenging and overkill. So some math is necessary there to have an approximation.

The order of ratios in gear-box is dictated by the ratio with a 0 which is neutral. So everything before it is reverse in reverse order, everything after is forward in normal order.
Something like this:
3.2
4.5
0.0
3.5
2.1
1.2

Means that there are two reverse gears, with 2nd reverse gear having 3.2 coefficient and 3 forward gears with 3rd having 1.2 coefficient.
Neutral gear is necessary, I have a small routine which looks for a gear with a 0 coefficient and remembers it as neutral, the rest of the gears a derived from there.

You need to tweak size of the sprocket too, depending on the size of the sprocket track will rotate with different angular velocity which effects RPMs. This could be the reason why it skips so fast through gears.
Correct, start of the torque curve is idle RPM.

Ah that makes a lot of sense :rolleyes:. I thought the sprocket radius setting had something with collision to do, so I left that untoched. Changing it to 91.44cm*(again, using that website as a point of reference)* made it a lot better. Feels a lot more like a tank now.

Edit:

Since I’m in the process of tweaking its various settings, there’s some settings which I’m either not sure what they do - or unable to get accurate information of(and don’t know the performance impact of). I’d greatly appreciate some information on those if possible;

Mu X, Y Static & Mu X, Y Kinetic: Not entirely sure what these do, but I assume maybe it’s something to do with how easily the tank slides…?
Rolling Friction Coef: Possibly tied to the above as well?

Transmission Efficiency: Unknown effect, left as default value.

Tread Length: Unknown effect, left as default value. (Also unable to find information about the total length of each track for the Tiger 1, as well as length of each link)
Tread Half Thickness: Unknown effect, left as default value.

Sleep Velocity: Unknown effect, something to do with deceleration?
Sleep Timer: Unknown effect, related to some of the driving logic I believe. (I recall having to set this to 0 when controller gives throttle input)

Gear up and down shift percentage I assume is at which % of the RPM the automatic gearbox should switch gears?

Thanks for being so helpful, greatly enjoying playing around with this plugin :smiley:

I think the best way to have the wheels of the locomotive (or any of the train cars that it is pulling), would be to have the wheel-sets attached to a block/box. This box would be separate from the main body of the locomotive, but it would still need to be linked to the locomotive. I think having each wheel-set have it’s own pivot points would allow more realistic movement while moving on track, because instead of having the locomotive move along a Spline based on a single pivot point, you are having each wheel-set do so.

I still don’t really think that the wheel alignment would be overly demanding on the engine, and it’s not overkill really. Somewhere down the line, someone will need something like this (a train thats movement needs to look believable enough that it won’t break the suspension of disbelief), and either there won’t be one and they don’t know how to code one in, or we will still have what we do now and it will still look terrible.

I honestly don’t know how the physics of a trains are more complex that that of a tank. Honestly I think a tank (or even a hovercraft) demands more physics input and performance then a train would. Tanks can move along a multitude of terrain types (bumpy, smooth, rocky and so on), but trains can’t do that really. That have to go where the tracks go, and you can’t lay train tracks on rocky terrain until you clear a path of level ground to start track laying.

Mu are friction coefficients in X and Y axis of the track. They can be used to imitate different design of the link. For example rubber tracks have more or less the same coefficients in X and Y, while some of the tracks used on M113 have a “graple” on each link which provides more traction in X direction than Y. The higher the coefficient the higher friction you get.
Rolling Friction Coefficient effects general resistance for the tracks to movement depending on speed. This is what limits tank’s top speed together with engine torque output at last gear.

It’s a sort of mechanical loss of torque when it passes transmission. Leave it as it is, in general you can set it to one and just tweak Engine Extra Power Coefficient.

It’s used to place links along the spline. As you have 3d model already, measure distance from one connection point of the link to another and multiple by total amount of links minus one, this should be the total length.

It’s used to scale up collision sphere I think, just make it bigger if you see that links clip through the ground when tank is on flat surface.

This is used to put physics to sleep when tank is stationary. Helps to prevent small drift and saves performance for other things. Default values should be fine.

Exactly, might want to tweak it if engine has a very wide RPM range.

Enjoy! I hope you will like new version too :slight_smile:

Tread Length doesn’t seem to be doing anything for me, whether I set it to 0 or some ridiculous value such as 5 000. It doesn’t change the appearance of the tracks nor the driving capability of the tank.

Then most likely it’s calculated from the lenght of spline.

Then wheels have to be moved along the splines? It’s a chicken and egg problem. Connecting wheel to bogie and bogie to locomotive won’t automagically solve it.
One approach is to calculate location of boggies first, in relation to each other. Then find their rotation from how wheels should be located along the rails, for example perpendicular to spline direction and then somehow calculate location and rotation of locomotive.
Second approach is physics based where you have to imitate friction of wheels with the rail and calculate the rest from there.

Been tweaking a bit and playing around with implementing functionality for the turret. It’s a very simple testing setup, I added a boolean variable to A_Tracked_Vehicle called TurretLock so I can change whether my 360 pad’s input goes to the throttle or turret. So far it rotates along yaw and the barrel pitches but I haven’t added any limitations yet. I also added a basic fire function but as you can see the force applied is a bit funky*(Used your MMT Ad Force at Location)*. I made a socket for the muzzle location and I’m using it as a location for the force. I’m still trying to figure out how to properly apply the force for realistic-ish recoil.

Sorry for hijacking your thread with all my updates :rolleyes:

https://streamable.com/gyzd

Still some performance tweaks to do, but I might continue that later. I think I’ll look into some multiplayer replication now and see if I can get the turret rotation to sync. After that some model tweaks as the turret model isn’t particularly accurate when it comes to the gun mantlet*(model probably wasn’t intended to be used for games)*.

I also found a bunch of awesome cutaway pictures, so I might try and model a basic interior for the tank*(I’m a terrible 3d artist, so it’d be the most basic of shapes)*. This really makes me regret selling my Oculus Rift DK2 a bit over a year ago. :rolleyes: