[OPEN-SOURCE] Machinery Modelling Toolkit

It works in pretty hacky way right now, because I don’t want to bring custom shaders into MMT just yet.
What I do is very similar to this tutorial:

the difference is that I don’t place deformation decals on the visible landscape but on the copy of the landscape deep “underground”. So visual landscape can get proper decals for marks, with color and normal map and ground deformation (which uses tessellation) can be always switched of for performance improvement. What I don’t like in this approach is that I have to spawn to sets of decals and they are pretty dense in how they are placed around, might be a hit to performance. I’m not seeing performance drop but I’m running it on GTX590 and current bottleneck is somewhere on CPU anyway.
A better approach which I will try later is similar to what WarThunder does - they don’t use decals but check for actual geometry penetrating “soft” landscape and use that for deformation. Which means that all kind of stuff can leave those marks, like overturned tank will leave tracks from its turret sliding over the hill, or explosions, rocks, fallen trees and etc.
Anyway, I want to sort of finalize this approach first.

Not sure what exactly SpinTires does, in our case if someone uses this kind of deformation we would have to solve other issue like for example character walking over such surface. Don’t have good ideas regarding this yet. Ideally a custom landscape with tessellation and some coarse collision mesh would be used.

Regarding Tiger, so where are you so far? Have you managed to assemble UpdateFriction function?

I’ve send you the current tiger if you want to check and test the torsion bar setup.

I added the ResetFrictionPoints function and did all the OnComponentHit events for the wheels in the event graph.

The next step is Update friction function, but i was waiting for a short descrition of the order you added it all.
I can just redo it the way you did it in the T26, and will probably work… but then I’m just copying and pasting stuff and have no idea what I’m actually doing.
And I’m trying to understand the way you think and set things up :wink:

Spintires has some crazy terrain deformation… don’t know if the demo is still out… but it’s fun driving through mud with a 4x4 and seeings the way it reacts.

SpinTires is a DX9 game so it can’t even use tessellation. It’s also taking the deformations into account in away that I don’t believe their collision model is that coarse (possible that they do the math on same data). If you need something like this, I think this could help to achieve it: Runtime Mesh Component - Marketplace - Epic Developer Community Forums! Other option would be to do make the displacement data both on gpu and cpu and use cpu version to offset the suspension values (would only work on linetraces and shape casts and not with actual physics geometry).

Also do note that if you have actual mesh there and not something that’s displaced with GPU, you can enable complex trace on the trace parameters to get per polygon response (instead of using the collision that’s used for other physics).

What did you do with the terrain?
All the vehicles based on the n-tracked blueprint examples like the m113 and the ripsaw… are not able to move on terrain. The old tiger1 based on the m113 also does not want to drive on the terrain anymore.
Did you change something?

I suspect that terrain underneath is confusing ray cast on suspension. For what ever reason Ripsaw is driving fine but M113 just gets stuck. I’ll check it.

Yes, the best way to solve is by using some custom technique to render landscape. Might be overkill for now. To make it work properly it have to be connected to streaming and etc.

So M113 hull is somehow gets stuck on something, if you enable debug mode (Alt+Shift+D) you will see that collision point is somehow outside of the M113 hull (pink point), which is weird 0_o.

Did you change anything in the code?

It’s also when you start a new scene… no driving on terrain and / or geometry

So, this is what I found - something happened to landscape. The collision is happening with heightmap of the main landscape. The landscape in another level (airplanes) works just fine. I found the way to replicate this issue, making a copy of the landscape creates this.
So no worries, we can fix this by not copying landscape :smiley:
I’ll try to make a level with this bug being reproducible and report it. Will work on the other piece of the guide now.

New scene is like new level or something?

Looking at Tiger right now:

  1. Don’t rotate root scene component of suspension, just leave it at 0,0,0. Instead rotate the SuspensionArm component.
  2. Now I see what you mean about suspension arms, that’s an unusual order, I thought that on both side there were bending toward the back of the tank. Here I see that right side bends to a back and left side to the front.
  3. I’ve set suspension arms to 25 degrees rotation in Y
  4. For stability of the physics constraints it’s important that connected components have not more than 10 times difference in mass (ideal), unfortunately as we are dealing with tanks we can’t have torsion bars weight a ton each. But something like 100-200 kg might make a trick.
  5. Projection settings I usually set to 0.1 Linear Tolerance and 1.0 of Angular Tolerance
  6. The collision components which will come in contact with ground, like Collision Wheels, Idler and Sprocket need to have SmallFrictionMaterial physics material, so they can slide easily over obstacles - it improves stability.

After setting all this, it seams to be working more or less fine. I’ll send you file back with the settings.

To set physics material easier you can do like this:
e7aa47f430a9c0d6c20efd578887776cd9343dd6.jpeg

Bug fixed, Yay! The solution to collision issues of M113 and A_Tracked_Vehicle is rather simple. We need to remove center of mass offset from A_Tracked_Vehicle’s root body, like this:

If center of mass offset is needed, then it can be set in a specific child blueprint like M113. The fix is on the github.

Continuation of the guide

“Update Friction” function is responsible for orderly calling “Track Anisotropic Friction” components to apply friction force to the tank. There are couple of things which a necessary to make it happen.
First we need to count how many friction points are in the contact with the ground or in collision with some obstacle. The other thing we need to provide is the velocity of the tracks. Tracks velocity is influenced by the engine and friction itself.

The velocity of the tracks is handled using Track Transmission Processor component. We need to add two of them, one per each track. Example of components and their settings from T-26 Light Tank:

Later, Track Transmission Processor can be replaced by Track Transmission Processor Modular which is build to work plug-in-play with Modular Drive Train. As to parameters, this is their meaning:
Reference Frame Component Name - name of the a chassis or root physics component of the tank
Sprocket Radius Cm - radius of the track sprocket in centimeters
Sprocket Mass - mass of the sprocket in kg
Track Mass - total mass of the track in kg
These parameters can be hard to find but they are important for the overall handling of the vehicle. Higher mass of the sprocket and track will make a larger inertia of track movement, which will make it harder to slow it down or accelerate. The heavier the tracks and sprocket the more power from the engine is necessary to spin tracks, especially in cases when we want to spin tracks in opposite direction for neutral turn.

Brake Force - is the amount of force that we apply to track when brakes are enabled
Mechanical Friction Static Limit - is a threshold of track acceleration, if acceleration is lower than this parameter tracks won’t move. This parameter imitates some of the mechanical binding that happens in transmission because of mechanical friction and inefficiency.
Mechanical Friction Kinetic Coefficient - is a unit-less parameter that effects how fast tracks will slow down without engine torque

“Update Friction” function need to be called from MMT Physics Tick event and receive delta time as input.
Inside of the function we will have three parts:

  • counting of valid friction points
  • setting parameters and calling TrackAnisotropicFriction component to apply friction force
  • gathering of reaction force and providing it as parameter into TrackTransmissionProcessor

To count valid friction points we need a temporary array of all TrackAnisotropicFriction components and local integer variable PointsCount:

For a second and third part we need two local vector variables RightTrackReactionForce and LeftTrackReactionForce, which we will use to accumulate reaction forces from TrackAnisotropicFriction->PhysicsUpdate() output.
This is how it all combines:

For each side of the tracks we have a loop out of corresponding TrackAnisotropicFriction components. In each loop, we get track velocity vector from the TrackTransmissionProcessor component and provide it into each TrackAnisotropicFriction component using UpdateTrackData function. Then we call PhysicsUpdate function, providing PointsCount (calculated earlier) and DeltaTime. The output of this function we accumulate into RightTrackReactionForce and LeftTrackReactionForce.

All what is left is to use SetTrackApplicationForce function of TrackTransmissionProcessor to provide reaction force created by friction back into the loop.

Thanx a lot! got some new homework again :wink:

I’ll also fix the center of mass offset … Let me see if I can manually change that in the blueprint instead of grabbing the new build from git.

Did you only change the A_TrackedVehicle Blueprint? Then that is the only file I have to replace…

Yes, just change it there, no need to get a copy. But copy it if you want. Just recompile child BPs after that change.

replaced… and it works now.

What I do find weird… when you go in you landvehicle map and take the m113 or ripsaw… and turn on debug mode… I still get a hull collision message popping up that it is hitting the ground when you go on the terrain.

You need to make sure that their Center Of Mass offset is set to 0,0,0 and recompile them. Had it on Ripsaw in current version and this is how it is solved. Perhaps Epic changed something in how the offset works, I would need to take a look at it later.