VehicleGame.Build.cs
PrivateDependencyModuleNames.AddRange(
new string[] {
"Slate",
"SlateCore",
"PhysX",
}
);
class UVehicleMovementComponentBoosted4w
VehicleMovementComponentBoosted4w.h
/** Wheel Lat Stiff */
UFUNCTION(BlueprintCallable, Category = "Wheel")
void SetWheelLatStiff(int32 WheelIndex, float LatStiffValue, float LatStiffMaxLoad, float LongStiffValue, class UTireType* TireType);
/** Wheel Friction*/
UFUNCTION(BlueprintCallable, Category = "Wheel")
void SetWheelFrictionScale(int32 WheelIndex, class UTireType* TireType);
VehicleMovementComponentBoosted4w.cpp
#if WITH_PHYSX
#include "PxVehicleWheels.h"
#endif //WITH_PHYSX
void UVehicleMovementComponentBoosted4w::SetWheelLatStiff(int32 WheelIndex, float LatStiffValue, float LatStiffMaxLoad, float LongStiffValue, class UTireType* TireType)
{
if (WheelIndex >= 0 && LatStiffValue > 0.01 && LatStiffMaxLoad > 0.01 && LongStiffValue > 0.01 && Wheels.Num() > WheelIndex)
{
Wheels[WheelIndex]->LatStiffValue = LatStiffValue;
Wheels[WheelIndex]->LatStiffMaxLoad = LatStiffMaxLoad;
Wheels[WheelIndex]->LongStiffValue = LongStiffValue;
Wheels[WheelIndex]->TireType = TireType;
// init tire data
// physx::PxVehicleTireData PTireData;
physx::PxVehicleTireData PTireData;
PTireData.mType = Wheels[WheelIndex]->TireType ? Wheels[WheelIndex]->TireType->GetTireTypeID() : GEngine->DefaultTireType->GetTireTypeID();
PTireData.mLatStiffX = Wheels[WheelIndex]->LatStiffMaxLoad;
PTireData.mLatStiffY = Wheels[WheelIndex]->LatStiffValue;
PTireData.mLongitudinalStiffnessPerUnitGravity = Wheels[WheelIndex]->LongStiffValue;
PVehicle->mWheelsSimData.setTireData(WheelIndex, PTireData);
}
}
void UVehicleMovementComponentBoosted4w::SetWheelFrictionScale(int32 WheelIndex, class UTireType* TireType)
{
if (WheelIndex >= 0 && Wheels.Num() > WheelIndex)
{
Wheels[WheelIndex]->TireType = TireType;
// init tire data
// physx::PxVehicleTireData PTireData;
physx::PxVehicleTireData PTireData;
PTireData.mType = Wheels[WheelIndex]->TireType ? Wheels[WheelIndex]->TireType->GetTireTypeID() : GEngine->DefaultTireType->GetTireTypeID();
PTireData.mLatStiffX = Wheels[WheelIndex]->LatStiffMaxLoad;
PTireData.mLatStiffY = Wheels[WheelIndex]->LatStiffValue;
PTireData.mLongitudinalStiffnessPerUnitGravity = Wheels[WheelIndex]->LongStiffValue;
PVehicle->mWheelsSimData.setTireData(WheelIndex, PTireData);
}
}