Physics go haywire and inconsistent when using "RecreatePhysicsState"

we wanted to replace the vehicle wheels during runtime and when we use “RecreatePhysicsState” the physics of the vehicle become very inconsistent. Here are the 3 ways it can go:

  1. physics go crazy and car starts flying around like a deflating balloon.
  2. car falls through the landscape and causes the engine to crash.
  3. It suddenly decides to work properly.

Due to this inconsistency I would like to know if there is a proper way of replacing wheels during runtime or before spawn or before the constructor of the WheeledVehicleMovementComponent4W is called.

Here is how I replace my tires. In my game, I replace my existing tire for empty tires to simulate a flat tire feeling. After replacing the certain tires with my empty tires. I remake the tires by running the follwing:

    GetVehicleMovementComponent()->WheelSetups = EmptyWheelsSetup;
    GetVehicleMovementComponent()->CreateVehicle();
    GetVehicleMovementComponent()->RecreatePhysicsState();

that’s what I’ve been doing too. I replace the existing tire, then do the exact same thing. but the physics then do one of the 3 things mentioned above. it happens when it checks for if the new transform is valid.

just had a look at the actor bounds for collision. and for the vehicles they’re massive. why is that? then it’s no wonder that the other error is that the bounds aren’t right.

sure.

UPCCVehicleMovementComponent* movementcomp = NewVehicle->GetPCCVehicleMovementComponent();
	UPCCWheelInfo* wheelobjF = wheelSettingsFront.GetDefaultObject();
	UPCCWheelInfo* wheelobjB = wheelSettingsBack.GetDefaultObject();
	TArray<FWheelSetup> tires;
	if (wheelSettingsFront != nullptr)
	{
		FWheelSetup wheelFL;
		//Left
		wheelFL.WheelClass = wheelobjF->WheelSettings.CustomWheel;
		wheelFL.BoneName = wheelobjF->WheelSettings.BoneNameLeft;
		wheelFL.AdditionalOffset = wheelobjF->WheelSettings.AdditionalOffsetLeft;
		wheelFL.bDisableSteering = wheelobjF->WheelSettings.bDisableSteering;
		tires.Add(wheelFL);

		FWheelSetup wheelFR;
		//Right
		wheelFR.WheelClass = wheelobjF->WheelSettings.CustomWheel;
		wheelFR.BoneName = wheelobjF->WheelSettings.BoneNameRight;
		wheelFR.AdditionalOffset = wheelobjF->WheelSettings.AdditionalOffsetRight;
		wheelFR.bDisableSteering = wheelobjF->WheelSettings.bDisableSteering;
		tires.Add(wheelFR);
	}

	if (wheelSettingsBack != nullptr)
	{
		FWheelSetup wheelBL;

		//Left
		wheelBL.WheelClass = wheelobjB->WheelSettings.CustomWheel;
		wheelBL.BoneName = wheelobjB->WheelSettings.BoneNameLeft;
		wheelBL.AdditionalOffset = wheelobjB->WheelSettings.AdditionalOffsetLeft;
		wheelBL.bDisableSteering = wheelobjB->WheelSettings.bDisableSteering;
		tires.Add(wheelBL);

		FWheelSetup wheelBR;
		//Right
		wheelBR.WheelClass = wheelobjB->WheelSettings.CustomWheel;
		wheelBR.BoneName = wheelobjB->WheelSettings.BoneNameRight;
		wheelBR.AdditionalOffset = wheelobjB->WheelSettings.AdditionalOffsetRight;
		wheelBR.bDisableSteering = wheelobjB->WheelSettings.bDisableSteering;
		tires.Add(wheelBR);

	}	
	movementcomp->WheelSetups = tires;
	movementcomp->CreateVehicle();
	movementcomp->RecreatePhysicsState();

Can you show me how you replaced your tires via Code?

and thisis the error I currently get:

+		Primitive	0x0000021a7926b040 (Name=0x0000021a3991f9c4 "VehicleMesh")	UPrimitiveComponent * {UE4Editor-Engine.dll!USkeletalMeshComponent}
+		Primitive->Bounds	{Origin={X=nan Y=nan Z=nan } BoxExtent={X=nan Y=nan Z=nan } SphereRadius=nan }	FBoxSphereBounds
+		Primitive->Bounds.BoxExtent	{X=nan Y=nan Z=nan }	FVector
+		Primitive->Bounds.Origin	{X=nan Y=nan Z=nan }	FVector
		Primitive->Bounds.SphereRadius	nan	float
+		UpdateParams	{Scene=0x0000021aa0340440 {World=0x0000021ae8e10b80 (Name=0x0000021a3991ec4c "TestMap") FXSystem=0x0000021aee6334c0 {...} ...} ...}	FScene::UpdatePrimitiveTransform::__l17::FPrimitiveUpdateParams
+		UpdateParams.LocalBounds	{Origin={X=nan Y=nan Z=nan } BoxExtent={X=nan Y=nan Z=nan } SphereRadius=nan }	FBoxSphereBounds
+		this	0x0000021aa0340440 {World=0x0000021ae8e10b80 (Name=0x0000021a3991ec4c "TestMap") FXSystem=0x0000021aee6334c0 {...} ...}	FScene *

it seems like the bounding box doesn’t get generated when I use the RecreatePhysicsState.

dunno if the reply is in review. if it is sorry for the double reply.
`UPCCVehicleMovementComponent* movementcomp = NewVehicle->GetPCCVehicleMovementComponent();
UPCCWheelInfo* wheelobjF = wheelSettingsFront.GetDefaultObject();
UPCCWheelInfo* wheelobjB = wheelSettingsBack.GetDefaultObject();

if (wheelSettingsFront != nullptr)
{
	//Left
	movementcomp->WheelSetups[0].WheelClass = wheelobjF->WheelSettings.CustomWheel;
	movementcomp->WheelSetups[0].BoneName = wheelobjF->WheelSettings.BoneNameLeft;
	movementcomp->WheelSetups[0].AdditionalOffset = wheelobjF->WheelSettings.AdditionalOffsetLeft;
	movementcomp->WheelSetups[0].bDisableSteering = wheelobjF->WheelSettings.bDisableSteering;

	//Right
	movementcomp->WheelSetups[1].WheelClass = wheelobjF->WheelSettings.CustomWheel;
	movementcomp->WheelSetups[1].BoneName = wheelobjF->WheelSettings.BoneNameRight;
	movementcomp->WheelSetups[1].AdditionalOffset = wheelobjF->WheelSettings.AdditionalOffsetRight;
	movementcomp->WheelSetups[1].bDisableSteering = wheelobjF->WheelSettings.bDisableSteering;
}

if (wheelSettingsBack != nullptr)
{
	//Left
	movementcomp->WheelSetups[2].WheelClass = wheelobjB->WheelSettings.CustomWheel;
	movementcomp->WheelSetups[2].BoneName = wheelobjB->WheelSettings.BoneNameLeft;
	movementcomp->WheelSetups[2].AdditionalOffset = wheelobjB->WheelSettings.AdditionalOffsetLeft;
	movementcomp->WheelSetups[2].bDisableSteering = wheelobjB->WheelSettings.bDisableSteering;

	//Right
	movementcomp->WheelSetups[3].WheelClass = wheelobjB->WheelSettings.CustomWheel;
	movementcomp->WheelSetups[3].BoneName = wheelobjB->WheelSettings.BoneNameRight;
	movementcomp->WheelSetups[3].AdditionalOffset = wheelobjB->WheelSettings.AdditionalOffsetRight;
	movementcomp->WheelSetups[3].bDisableSteering = wheelobjB->WheelSettings.bDisableSteering;
}
movementcomp->CreateVehicle();
movementcomp->RecreatePhysicsState();`