Add Torque to physics controlled player, to return roll to zero

Jubilation! Four days later, I figured it out. It’s so flipping obvious with hindsight :slight_smile:

The PID worked perfectly, but the tutorial I followed was designed for throttle input. So the error range for which would be 0 to 1. I needed it to constantly correct my physics pawn’s roll to zero, so the error range would be -1 to +1 (expressed as an element of a normalized vector) or -180 to +180 (expressed as an element of a rotator).
image

Once I adjusted this, I used the z value of the actor’s right vector (imho vectors are more robust than UE’s quirky rotators) to feed in a the error that the PID corrects.

I’d like to give HUGE kudos in a shoutout to Chuck Noble, Tech Director at both Fun Dog Studios and Gamergenic for his incredibly-detailed-yet-easy-to-follow post on how to do a PID in UE5 in both BP and C++.

1 Like