I thought I’d share my solution to a major problem I had this week.
PROBLEM:
With the slightest Throw from my joystick or mapped key to move forward my tank would launch forward and often into a wild spin. It was completely uncontrollable. You should have seen the AI trying to steer lol… Unreal 4.21.
WHAT I TRIED:
For the record, I was meticulously careful to copy Ben and Sam. I Checked Out their repo, triple checked I shared the same code, I even remade my Tank_BP from scratch.
I adjusted MaxDrivingForce (a low MDF prevented me from turning), linear and angular dampening (which was negligible to the force that would hurl my tank forward), and I spent hours examining colliders and any relevant settings in the SprungWheel_BP. Honestly, everything was IDENTICAL.
SOLUTION:
I remembered Ben had reset the CurrentThrottle in the Avoiding Boolean Flags video after applying the driving force. So in my USprungWheel::OnHit( … ) function, after ApplyForce() I set the TotalForceMagnitude = 0.
That did it! My tank was controllable and linear dampening actually made a difference for tweaking.
It introduced another problem of my tank weirdly flipping as if there were a huge weight on one side pulling it over. I increased the mass to 80,000kg and now it is fine but not perfect. (Also tried introducing another physics constraint and adjusting COM but none were really effective) It’s not as smooth as Sam’s tank when I cloned his repo but it’s certainly the best its ever been. Definitely good enough to move on from it.
I hope this solution helps because it took me probably close to 20 hours of grinding to figure this out. At the very least, my Game Dev experience points are on the rise!