How to set Lock Position and Lock Location on Component in C++?

Hi there,

In BP, when you edit a component you can seperately select the three axis for Lock position and Lock rotation. I can’t seem to find functions that allow you to do this in C++. Anyone have an idea on how to do this?

79548-lockpositionandrotation.png

Thanks!

You can access those settings via the body instance of that component.

//Assuming that Comp is a UPrimitiveComponet or derived from it.
{
//...

    if(Comp && Comp->GetBodyInstance())
    {
        Comp->GetBodyInstance()->bLockYTranslation = true;
        Comp->GetBodyInstance()->bLockXRotation= true;
        Comp->GetBodyInstance()->bLockZRotation= true;
        Comp->GetBodyInstance()->SetDOFLock(EDOFMode::SixDOF);
    }
//...
}
1 Like

and related question: in the settings I show in the screenshot, would I accomplish the same with SetConstraintMode(EDOFMode::XZPlane)? Or is there a difference?

Yeah, it should do the trick

Thats work Thanks :slight_smile: