Modify Angular Rotation Offset at Runtime

Is it possible to modify the angular rotation offset of an physics constraint at runtime with blueprints ?
If not, is it possible in C++ ?

Thank you.

26925-unreal+question.png

Hi Sprawl,

No, it is not possible in blueprint, because this property uses only during constraint initialization. In C++ you can setup this variable and call UpdateConstraintFrames or InitComponentConstraint, but it can lead to some performance problem (if do it every tick).

Best regards,

1 Like

Thank you for the answer ! It is really appreciated.

If this is the basis of my gameplay and only one object is calling it every tick, do you think it will have a significant impact on performance ?

I made a doorway blueprint that uses a Physics Constraint to stop the door from opening too wide.

But I also exposed a public variable for StartingAngle. The BP Construction script sets the rotation angle of the door. This way I can use the same BP for doors that are either initially closed or partway open.

The problem is the physics constraint seems to be applied after the Construction Script rotates the door. So it ends up not closing (and opening too wide).

I either need 1) access to the Angular Rotation Offset in the BP Construction script or 2) a change in the behaviour of Physics Constraints so they respect the original position of the door prior to its rotation in the BP Construction script.

Maybe there’s another way to rotate the static mesh that I’m not aware of.

Any help would be appreciated.

constraint->ConstraintInstance.AngularRotationOffset = FRotator(0, 90, 0);

I’m currently attempting creating the exact same blueprint as you, and encountered the same problem. Did you ever figure out how to solve it? Or an alternative work-around?

I would like to know this as well, as I am attempting the exact same thing and encountering the same problem.
Edit: Ok the simplest (Blueprint) work around that I found and works for that is just to have a StartingAngle variable like LazyMammal described, and use that to rotate the door with AddRelativeLocation in BeginPlay, (so after the constraint has been initialized). Obviously it’s not the greatest solution, there is unfortunately no ‘preview’ in the editor of your angle unless you create a seperate HiddenInGame mesh for that as workaround for example.
What works better for me, in C++, is doing combining cin and 's answers and modifying the AngularRotationOffset like this, in BeginPlay:

    PhysicsConstraintComponent->ConstraintInstance.AngularRotationOffset -= FRotator(0.0f, DoorMeshComponent->GetRelativeTransform().Rotator().Yaw, 0.0f);
    PhysicsConstraintComponent->InitComponentConstraint();
1 Like

I have a workaround for it.
Create a scene component use it to change the rotation of the physics constraint reference frame not the actual physics constraint. Here Constraint Ref Frame is a scene component. “Frame” is used to reverse the z axis.
(NOTE: Use relative rotation of the scene component, i have done mistake in the image)