Preventing a vehicle from rolling

I’m using the vehicle movement component for my player pawn and I want to prevent it from rotating about any axis except Z. The terrain it drives on is completely flat so no need to worry about it looking odd when going up hill or anything like that.

The problem I’ve run into is that if I drive along a wall while turning in the direction of the wall sometimes the physics will just flip me onto my side. I’ve tried increasing the mass of the vehicle, increasing the X and Y IntertiaTensor and lowering the Center of Mass but nothing has worked for me so far. Any suggestions?

1 Like

Did you ever find a solution to this?

Unfortunately, no.

I actually ended up finding a solution from the Unity answer hub, so I’ll post that as an answer for anyone needing this in the future

So I ended up finding the answer to this question [here][1]. I converted the C# to BP and posted below. Note that instead of applying a torque I ended up just making it an angular acceleration change. If you want to apply torques you’ll have to take mass into account. I hope this helps someone else who ends up having this issue in the future :slight_smile:

Thank you vdwtanner! You’re a star, this works really well.

Awesome! Glad to hear I was able to help!

Hey, if you’re still active, what values did you use for speed and stabilizing speed?
EDIT: also when do you call the function, on tick?

I found that using .5 for Stability and 1 for Stabilizing Speed to be a good start. And yes set it on tick.

@vdwtanner

< Note that instead of applying a torque I ended up just making it an angular acceleration change. If you want to apply torques you’ll have to take mass into account. >

I’m not seeing a node called “angular acceleration change” But I’m using “Add Angular Impulse In Degrees” and it seems to be working, but I’m not positive because my vehicle still is able to flip, but certainly less often. Any recommendations on a better node to use to effect angular acceleration?

Thanks for the script!

This doesnt seem to do anything in 4.22.2 car still flips on side anyone had luck with this on this version?

Didn’t understand what values should I give in stability and stability speed variable to work porperly.