How to dynamically control acceleration of a vehicle

Hey guys, I’m trying to control the acceleration of a vehicle dynamically. The purpose is to have different acceleration rates + max speed such that vehicle will travel in different speed across different roads. (Ex, Highway → Fast, city road → a bit slower, mud → very slow). It seems that friction does not do anything when the vehicle is going forward (which makes sense since the friction should only relate when the vehicle’s wheels are skidding, not rolling). Setting MaxRPM dynamically does not work :(. And I can’t set the velocity of the vehicle either. (there is only get function).

Please Help! Thanks in advance

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);
	}
}