Wheel Physics

So I’m trying to simulate wheel physics. I’ve got a skeletal mesh with four convex hulls for the wheels and one convex hull for the body.

I’ve constrained the XYZ motion to locked and constrained XZ angular of the wheels. So the wheel rotates on the Y axis. This all works well, except when I apply torque to the wheels, GetUnrealWorldAngularVelocity() gives me only about 400 and won’t go any higher. No matter how much angular velocity I add (see 4000 below), it won’t return anything higher than 400. The vehicle crawls along extremely slow. I’ve tried using AddTorque() but it doesn’t do anything to the wheels.

I also have a Physics Material with all of the defaults properties applied to all of the bodies. I’ve adjusted all of the values and none of them allow the vehicle to drive faster.

FYI, this is for a tank vehicle. For now, I’m only simulating four wheels for testing but if I can get everything working properly, it will probably end up with ten wheels.

See the code below.

FBodyInstance* Wheels[4];
Wheels[0] = SK->GetBodyInstance("FL_Wheel");
Wheels[1] = SK->GetBodyInstance("FR_Wheel");
Wheels[2] = SK->GetBodyInstance("RL_Wheel");
Wheels[3] = SK->GetBodyInstance("RR_Wheel");

for (int i = 0; i < 4; i++)
{
	Wheels[i]->SetAngularVelocity(FVector(0, Movement.X * 4000, 0), false);
}

Thanks for the help.

Hi,

The reason for this is that the maximum angular velocity is by default set to 400.
This value will be exposed in the upcoming release so you’ll be able to just set it as a property of BodyInstance.

The latest source in github master branch should already have the change if you’d like to take a look:

/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp
/Engine/Source/Runtime/Engine/Classes/PhysicsEngine/BodyInstance.h

You can see the changes related to:
/** The maximum angular velocity for this instance */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Physics, meta=(editcondition=“bSimulatePhysics”))
float MaxAngularVelocity;

I’d recommend waiting for the official release though unless you need this fix right away.

Thank you for the quick reply.

This is not exactly an issue that is immediate. However, is there anyway to get my vehicle to move faster without either a) waiting for the next official release or b) downloading and compiling the engine source code?

I’d like to know if I’m even doing this correctly and that adjusting the MaxAngularVelocity would actually fix my problem or would be the correct way to handle this. I could add an impulse or force to the main root body but that just doesn’t seem right. The way real wheels work is that torque is applied to the wheels which propels the vehicle forward. Adding force or an impulse feels more like I’m strapping a rocket to the back of the vehicle.

Thank you and again, I really appreciate the help.

So I’ve downloaded the latest master release on GitHub so that I can modify the maximum angular velocity. Got it all downloaded and compiled. Was able to SetMaxAngularVelocity on my BodyInstance but unfortunately now what happens is my vehicle stutters along and bounces. I’ve tried both with friction set to 0, 1, and many values in between. Also tried playing with restitution. For an FYI, the model is exactly to scale (about 37 feet long, it’s a tank).

However, as I am typing this, I just realized that my mass came in at about 2300kg, which is roughly 2.5 tons. A real world tank should be about 30-50 tons (heavy tanks). So obviously I need to adjust my mass to reflect more in that range. This could be the cause of my problem. I am my day job at the moment and don’t have access to my development tools. I will try this when I get home.

However, I’m just asking if anyone can point out a way to address my problem. If the mass is an issue, then hopefully I’m good. However, I am wondering if I am approaching wheels for vehicles totally incorrectly.

Thanks.

I just want to add an update to this in case anyone else is having issues with creating wheels for vehicles. Using the SetMaxAngularVelocity helped to allow more forward movement. Secondly, fixing my mass (which I figured would make a big difference) helped to remove the bounce and jitter when moving. So my tank now weighs about 48 tons and is about 37 feet long, which is very accurate to real world size and weight.

Thank you for your answer, Ori Cohen. I have marked your answer.

You got to re-mark your answer after you posted a comment, including mine.