Download

How to modify vehicle properties during runtime?

I’m currently evaluating UE4 for a game that primarily consists of vehicles but I have hit a bit of a snag.
I’d like to be able to modify a vehicles properties during runtime without having to destroy and recreate the vehicle, the following types of changes do not seem to take effect unless I do so.



VehicleMovement->COMOffset = FVector(0.0f, 0.0f, 0.0f);
VehicleMovement->MaxEngineRPM = 1000;
VehicleMovement->Wheels[0]->LatStiffValue = 1000;
VehicleMovement->Wheels[0]->LongStiffValue = 1000;

These are just examples but it seems that any changes made to the VehicleMovement class during runtime are not reflected until the vehicle is respawned.

I’m assuming or perhaps hoping that I am doing something wrong and that these types of changes are supported by the engine.

I really need to know about this aswell but ive been looking around for the past two days and haven’t found anything yet apart from calling SetupVehicle() afterwards but that just breaks everything and the car stops working all together

just found this might be of interest


void UWheeledVehicleMovementComponent::PostEditChangeProperty( FPropertyChangedEvent& PropertyChangedEvent )
{
	Super::PostEditChangeProperty( PropertyChangedEvent );

	// Trigger a runtime rebuild of the PhysX vehicle
	FPhysXVehicleManager::VehicleSetupTag++;
}

void UWheeledVehicleMovementComponent::PreTick(float DeltaTime)
{
	// ... blah...

	if (VehicleSetupTag != FPhysXVehicleManager::VehicleSetupTag)
	{
		RecreatePhysicsState();
	}
}

How would i apply this in a function where i change all the handling data? im struggling to understand how to apply it