[OPEN-SOURCE] Machinery Modelling Toolkit

Sure, post here any question you have and I’ll try to reply when I can.

Overall, there are two versions of the tracked vehicles implementation:
Old one, based on A_TrackedVehicle class (M113 and Ripsaw), which is outdated in terms of features and mostly done in BP. It has quite a few bugs that are not fixed and won’t be fixed as it’s deprecated.
New one, used for T-26 “LightTank” is based on C++ components, which are orchestrated in BP. The most feature complete example is LightTankWithAnimBP (if I recall name correctly :D), you can find it in the main level next to hovercraft and old tanks.

The main loop of the simulation can be seen in the main event graph under the MMT Physics Tick event.

  • It starts with updating torque produced by the engine.
  • Then torque is fed to track simulation component so new angular/linear velocity of the track can be calculated.
  • To calculate friction between track and the ground, we need to know how hard tank presses on the ground. For this we update suspension components that find where roadwheels/tracks would collide with the surface and how much force each suspension spring will produce.
  • Now we are ready to calculate friction/traction but first we count how many points of the track are in contact with the ground by checking status of suspension component.
  • At this point we know how many points (and where) are in contact with the ground and what kind of normal force is produced there as a result of suspension. From this and velocity of the track friction force is calculated. Calculation of friction force takes into account friction coefficient so tracks can skid. Part of the produced force pushes tank forward and opposing force pushes tracks in reverse.

Rendering/animation loop is separated but based on the results of the simulation loop. The only code heavy part there is animation of the track. Which is based on moving control points of the spline component and then placing instanced static meshes of links along this spline. Extra math is done to make sure that links are synchronized with sprockets.

Not so obvious part is how everything talks to each other. There are a lot of assumptions done of how parameters to functions are passed and when it is done. Unfortunately I haven’t seen a better way on how to keep it modular. It makes it more difficult to use, but one can assemble a different type of vehicle rather easy this way - 4 Wheeled Vehicle example is made mostly from the same components as tank.

Feel free to post here any questions you have. There is a lot of information about system in this thread, but some of it is not too easy to find.