Tank Physics Issues

Hello to Unity community!

I am making realistic tank physics in Unity using standard WheelCollider. And now I faced with some problems.

1. WheelCollider friction on slope.
Tank can’t climb slopes, even on small. For example, 10 degree slope stops tank completely. I played with friction and substeps, but unfortunately its not work. In Unity 4 was been ability to max out friction, in Unity 5 it makes your vehicle explode in space.

WheelColliders config:

Substeps is 40.

2. WheelCollider sleep.
As you know tank can turn on place, and there is second issue. I dont know why, but when tank turns on an uneven surface and angular velocity falls around ~0.5m/s, WheelColliders dont respond on torque, they like became asleep, tank just stops, and start again, and so on. However on flat surfaces its doesnt happen.

I tried a lot of things, and none of them didnt work, maybe you know how to fix this, Thanks!

2887538--212183--wc.png

Easiest fix is dont use wheelcolliders for a tank. They dont make any sense for tanks.

In Unity 4 it works pretty well. So there is no workaround in Unity 5? What I need to use for tanks instead?

@Emilyanis Your issues are related to the WheelCollider itself in Unity 5. You’ll encounter the same issues when simulating any vehicle in Unity 5. These problems are caused by the bad design and implementation of vehicles in PhysX, the underlying physics engine used by Unity. The best solution so far is using any of the vehicle packages available at the Asset Store as starting point, instead of the WheelCollider alone.

@JamesLeeNZ I think that WheelColliders can also be used for track-based vehicles. They can do a good job as long as the wheels on each side are configured to rotate together (hard link). Of course there are some limitations, but still is an easy and convenient method.

I consider wheelcolliders on a tank a bunch of un-nessesary physics work, for little gain, especially considering that real tanks dont work this way… Its the tracks that cause the movement (yes I know the wheels drive the tracks).

Personally I use MovePosition/MoveRotation and think it works the best for tanks.

Its not like the wheelcolliders are some amazing tech that should be put into everything that has a wheel… They are notorious for being the opposite of amazing tech…

1 Like

I thing the wheel approach is very convenient for simulating the torque and friction accurately in tracks. I don’t mean WheelColliders specifically, but using “wheel entities” as tracks.

Each track receives a specific amount of torque. This is all the torque the entire track can convert as traction force. Each single segment in the track is supporting a specific load value. Thus, it can apply traction and provide friction in a specific way different from the other segments.

Example: if only one segment of the track is making contact with the ground then all the torque provided to the entire track will be applied as force by that single segment. If many segments are touching the ground then the provided torque will be delivered among these segments and they will convert it into forces based on their specific situation.

Thus, tracks can be “easily” modeled as wheels: it just requires a constraint among all the wheels for them to co-rotate at the same exact rate. With this constraint properly implemented any torque applied to the track will be delivered to the wheels so the wheel set accurately behaves as a real track, including forward and sideways sliding based on the coefficient of friction of the track with the ground, torque applied, and velocity of movement of the track (= rotation rate of the unified wheel set).

As sidenote, this is also the model used by PhysX for Tanks:
http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Vehicles.html#pxvehicledrivetank
“Tanks are different to multi-wheeled vehicles in that the wheels are all driven through the differential in a way that ensures that all the wheels on the left-hand side have the same speed, and all the wheels on the right-hand have the same speed”

My own implementation doesn’t even need a differential. It uses two independent Direct Drive engines, one per track, simulating the real hydraulic engines that move the tracks in most track-based vehicles.

2 Likes

Still not convinced.

The biggest benefit of the wheel collider is steering. If I dont need car steering behavior, I dont use a wheel collider.

I can speak for my own experience only. Having two rows of wheels (WheelCollider) with no steering can conveniently simulate tracks and provide steering behavior. Just make each row rotate at different rates and the vehicle will steer as result. One side row rotating forward while the other rotates reverse at the same rate provides the so called “neutral rotation”, where the vehicle spins around its center.

This technique actually works pretty good simulating some uncommon vehicles:


In the latest case, none of the 8 wheels has steering but each row of wheels can rotate at a different rate. This provides all possibilities of steering, from very slight steering to neutral rotation.

1 Like

If you don’t need super accurate physics (like wheels on tank tracks), (in most cases don’t) you can easily apply torque, or opposite forces for turning, to rigid body, to get same result. Much cheaper for performance reasons. And most cases, unnoticeable.

There was post recently, where OP wanted to apply wheels physics to a train. For game application, such are unnecessary.

@Edy how do you control sideways friction of the wheel colliders for steering? Are you doing it dynamically by speed? I.e low speeds have more slip to allow for zero turn radius?

Also, any tips on setting mass for tanks? Im struggling to figure out the relationship of tank mass, wheel mass, spring and damper values, and wheel torque.

Thanks!

Few years back I was modding wheel system for one of games.
If I recall correctly, I used side forces per wheel to turn, as I described above.
And traction made by sideways friction.

But with new wheel system, don’t know if that same setting will work. Probably not.

I assume you’re referring to this vehicle, as it’s a wheeled vehicle that allows neutral steering (zero radius):

3689569--303685--upload_2018-9-18_1-25-18.png

All 8 wheels are standard wheels with no special considerations. The 4 wheels in each row are “linked” so they’re forced to co-rotate at the same exact rate. Just imposing different rotation rates at each side causes the vehicle to steer. Rotating one side forwards and the other side reverse at the same rate causes a neutral steering (the vehicle rotates around its vertical axis). It’s the same as in the real vehicle.

I’m using real-scale masses. I.e. the bulldozer weights around 110 tons. For suspension, you may follow the guidelines here as starting point:

https://vehiclephysics.com/user-guide/vehicle-setup/#suspension

How are you hard linking wheelcolliders to rotate at the same rate without needing to modify torque? The only way I can think of limiting wheel rpm is by checking it against a master wheel and taking away or adding torque.

I use three locked differentials per track. As result, torque is automatically computed for each wheel based on its specific state. I.e. if only one wheel is touching the ground, all torque is delivered to that wheel.

Note that I use Vehicle Physics Pro, where differentials may be configured in a perfect “locked” setup so both ends are forced to rotate at the same rate, even if the differential’s input is disconnected.