> MAJOR UPDATE
The physics embedding in UE4 is somehow difficult, especially if you work with staticmeshcomponent.
For instance: Constraints jsut change behaviour if you use the initialise function in c code, they act suddenly like loose shackles instead of joints…so i got rid all the blueprint embedding, i just kept 6 sockets with 6 very small static meshes as placeholders for the initialise function.
All the rest is done in
C++ CODE
now. (if you listen closely, you may hear a fine “TAADAAA” here lol)
Here is my current state of work:
Features:
- 6 sockets measuring their height and the reflecting impact-normal to the terrain with a collision routine (HItResult with WorldStatic setting so far)
Each wheel(socket) calculates a progressive spring rate depending on the hit result, suspension inbound travel and suspension max inbound value.
An additional damping is applied when the suspension has high travel velocity to avoid too much bouncing of the tank after jumping
The calculated force is scaled with a cosine function and a small magic threshold by the impact normal from the HitResult and the rotational offset of a normailzed up-vector, rotated by the tnaks current orientation and then applied to the related socket.
Since i did not get angular movement into the tank (roll & pitch) just by adding force to different socket positions as i wanted to, I calculate an angular force impulse for each wheel(socket) by position of the soket and suspension inbound ratio and apply it to the tank.
- spring rate and suspension heigt blueprint settable
- damping for inbound and outbound blueprint settable
- Any wheel with positive HitResult triggers the DRIVE function on its track side, so no speed can be applied when doing aerial stunts.
- complete track-section with the hitevent is removed from code
- the bug with the tracks getting stuck in the terrain and flipping the tank is fixed with this. There are no colliding components at all hitting the ground. If the tank jumps high and lands hard, then the suspension will inbound so much, that the tanks body collides with the terrain, just like in real life.
I am quite happy with the result so far, it needs a bit more tuning etc though.
Next step will be adding friction to the ground and calculating it into the tanks movement to get rid of the ApplySidewaysForce function, which is right now in use again.