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.