Download

updating physics constraints in runtime? Can PHAT params be changed?

I have a vehicle that is moving based on parameters/constraints set in its PHAT. Presently the vehicle moves correctly in a scene, driven by physics: in particular, I set the angular “velocity target vector” and the “angular velocity strength” in the editor. Works great. Am able to simulate a wheeled vehicle nicely. I want to change these constraints in play, however, and while I am able to change them in c++ (code snippet at bottom) the pawn does not seem to recognize nor act on the change parameter. It keeps doing what it was doing. Have hunted and tried a ton of “update” and “reset” kind of functions on the SkeletalMesh and the constraint itself, but am unable to effect any change in the behavior of the pawn.

So I imagine there is some kind of “recalculate physics now because parameter has changed” function, but I can’t locate it. If there is, can anyone suggest it?

It may also be that you can not change a physics parameter while in a running simulation, but I hope that it not the case.

Below: code snippet that changes the Y value of the angular target vector. By switching it from positive to negative, I should see the vehicle stop spinning in place and drive forward (it is a differential drive vehicle) however the change of value does not result in a change of behavior at all:

for (FConstraintInstance * con : mesh->Constraints)
	{

		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::White, FString::Printf(TEXT("Y:%f"), con->AngularVelocityTarget.Y )); //too screen

		//con->angularvel


		if (con->AngularVelocityTarget.Y > 0)
		{
			con->AngularVelocityTarget.Y = -1.0f;

                     }

//NOW What? This will make the change to parameter, but the pawn/actor does not seem to recognize anything has changed.

I’ve found the same problem only I’m using blueprints to set the linear drive velocity target at runtime, have you found any info about this since you posted?