Lock actor rotation to up vector

I’m sure that this is easy to do with PhysicsConstraints or something similar, but I’ve been working on this for the past few hours and my brain is totally warped right now.

Is there any way to only allow a pawn to rotate around its up vector? i.e. so it won’t fall over, but I’d be able to program it to walk on slopes or up walls

I’ve tried a lot of different things with EDOFMode::CustomPlane, but that doesn’t seem to work. It only allows me to lock it around the zaxis.

my current theory is to do this at the start

Capsule->GetBodyInstance()->CustomDOFPlaneNormal = GetActorUpVector();
Capsule->GetBodyInstance()->bLockRotation = true;
Capsule->GetBodyInstance()->bLockTranslation = false;

and then update the CustomDOFPlaneNormal every time the actor is rotated, but this doesn’t seem to work

I figured it out, I had to call

Capsule->GetBodyInstance()->CreateDOFLock();

after updating the plane’s normal.