Download

Help to Set Vehicle Mass in realtime (almost working)

Hello, i need help to Set Vehicle Mass in realtime, the problem is that Inertia Tensor Scale increases with new Mass Value and does not reset back.

cpp:


#include "SalkiGame.h"
#include "SalkiVehicleMovementComponent4W.h"

DEFINE_LOG_CATEGORY(SalkiVehicleMovementComponent4W_Log);

USalkiVehicleMovementComponent4W::USalkiVehicleMovementComponent4W(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
}

void USalkiVehicleMovementComponent4W::SetVehicleMass(float newMass, FVector newInertiaTensorScale)
{
	Mass = newMass; //set new mass value
	FixupSkeletalMesh(); //Not sure if it is doing something
	SetupVehicleMass(); // Updates the VehiclePhysX with new Mass but Ruins Inertia Tensor Scale
	InertiaTensorScale = newInertiaTensorScale; // Doing Nothing
	//SetupVehicle(); // - Ruin all Vehicle PhysX
	UpdateSimulation(World->GetDeltaSeconds());
	UE_LOG(SalkiVehicleMovementComponent4W_Log, Warning, TEXT("InertiaTenzor = %f"), InertiaTensorScale.X);
}

554bdc617ecdb4ce9193255dd7286684edda584a.png