[Chaos Vehicles] WheelMass not editable and hardcoded to 20 in source?

In PhysX Vehicles we could set the wheel mass on the Wheel blueprint, and the Chaos documentation indicates this is editable as well but the property doesn’t exist on the blueprint. I did some digging in the wheel base class and noticed that there is code commented out that would have read the property and instead it’s just hardcoded to 20. This value is part of the wheel inertial value so would think we would want to be able to edit it. Wondering if this is a miss that will be addressed in future release. For now, I think I’ve hacked it with my derived class and an ugly const cast since the wheel structure is not editable or exposed.

header file

UCLASS()
class VEHICLEGAME_API UBaseVehicleWheel : public UChaosVehicleWheel
{
	GENERATED_BODY()

public:

#if WITH_EDITOR
	virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
#endif 

	virtual void Init(class UChaosWheeledVehicleMovementComponent* InVehicleSim, int32 InWheelIndex) override;



private:
	void UpdateWheelConfig();

private:

	UPROPERTY(EditAnywhere, Category = Wheel)
	float WheelMass { 20.0f };
	
};

cpp file

#include "BaseVehicleWheel.h"
#if WITH_EDITOR
void UBaseVehicleWheel::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
{
	const FName PropertyName = PropertyChangedEvent.Property ? PropertyChangedEvent.Property->GetFName() : NAME_None;
	if (PropertyName == GET_MEMBER_NAME_CHECKED(UBaseVehicleWheel, WheelMass))
	{
		UpdateWheelConfig();
	}

	Super::PostEditChangeProperty(PropertyChangedEvent);
}

#endif

void UBaseVehicleWheel::Init(UChaosWheeledVehicleMovementComponent* InVehicleSim, int32 InWheelIndex)
{
	UpdateWheelConfig();

	Super::Init(InVehicleSim, InWheelIndex);
}

void UBaseVehicleWheel::UpdateWheelConfig()
{
	const_cast<Chaos::FSimpleWheelConfig&>(GetPhysicsWheelConfig()).WheelMass = WheelMass;
}

1 Like