Setting Position Target on Physics Constraint in C++ not working

So I’m trying to set the linear targets when the drawer has been interacted so it will open and close upon interaction.

Here is my code in c++ :

		Info.PhysicsContraintComponent->SetLinearPositionTarget(NextLoc);
		Mesh->WakeAllRigidBodies();

It is getting called, I made sure of it by printing the values of the location, The weird part is when I do it in blueprint exactly as it was in c++. It works!

image

Here is the blueprint I also tested it. What I found during runtime is the Linear position remains 0 when setting it in C++ which is very weird. I don’t want to make a messy workaround where I use a blueprint event.

Anybody have a rough Idea on what’s going on?

I am also getting this issue - constraintInstance.SetLinearDriveParams(10000.f, 1.f, 0.f);

constraintInstance.SetLinearPositionDrive(true, true, true);
constraintInstance.SetLinearPositionTarget(targetBoneLocation - controlledBoneLocation);

Doesn’t make any difference at all

Hi!

If I’m not mistaken, The Linear Position Target in PhysicsConstraint, You must convert world to local. I’ve also had this issue and make sure to call WakeRigidBody() after modifiying the physics constraint values.

I got mine to work after deleting the temp file on the project and generating it back again.

thanks for the info.

I found another post which said to increase the Position Iterations in the project physics settings.

This seemed to work for me (not totally, but enough).