PhysX Vehicle - Drive at target speed

Hi,

I am using Unreal Engine 4.20.3 and need help making a vehicle drive at a specified speed.

If I have a vehicle driving at 100km/h, and in 200m time it needs to be driving at 80km/h, how would I calculate how much the brake needs to be applied?

I can calculate how much force the brakes need to apply to the vehicle with the following:

``````float CurrentKineticEnergy = (VehicleMovement->Mass * 0.5) * FMath::Square(CurrentVelocity);

float TargetKineticEnergy = (VehicleMovement->Mass * 0.5) * FMath::Square(TargetVelocity);

float Work = (CurrentKineticEnergy - TargetKineticEnergy) / NumberOfWheels;

float Force = Work / Distance;
``````

I can also work out the force of the brakes when they are fully applied:

``````BrakeForce = MaxTorque / WheelRadius;
``````

I am struggling to tie this together however. Reading the code I have been unable to find anything on braking/stopping distances or friction coefficients.

If anyone could point in me the right direction I would be grateful!

Thanks,
Dan

I’m not sure this can be reasoned with any accuracy. In-between the brake and the rigid body are four tires with non-linear responses to slip angle. The problem, then, is that the braking torque doesn’t convert linearly into a force on the rigid body. It gets much more complex if you want the vehicle to turn while it is slowing.

Your problem is more even complex because you require a non-linear deceleration. I’ll try to explain that. If you assume linear acceleration then we can write down an equation for the distance travelled as a function of time