Let’s start with a review of the last 4 weeks ( please keep in mind, i am no Pro Coder with tons of time and godlike abilities…)
This is the state of development 4 weeks ago:
Its basically what you get from Ben Tristems tutorial plus my first skript kiddy attempt:
Using constraints and there settings…so i got this:
A lot better then the one form the tutorial, which is just a moving block with massive physics issues, but imho a total fail.
Physics and Blueprint Constraints drive me mad, do not do what i want them to do…just a FAIL…attempt dumped.
So then i started coding this in C++
Here is state of work about 3 weeks ago:
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.