Can someone explain the random nature of wheel colliders

44 Views Asked by At

Summary: I have been working on a car game in Unity and every time I use wheel colliders the behaviour is different. I created a super simple box object, copy/pasted it, and the behaviour between the duplicates was inconsistent. The only thing I can think of is frame rate, but this test scene has nothing but one object, a camera and a plane so that doesn’t sound plausible.

Details: There is almost no code involved, except an Addforce script and a LookAt script for the camera.

I created a cube and modified the size to (1, 1, 2) added a rigid body (weight 500) I added an empty perfectly in the center called “colliders” I added four wheel colliders, and perfectly positioned them equidistant apart. Used default settings 1 and -1 left and right 0.5 and -0.5 back and front

I dropped added a plane and hit run, the object dropped onto the plane and floated there no problem.

Now, I added an addforce script to cube, when I press “a” Rigidbody.addForce(vector3.forward * force Force is a public variable I can change The object won’t move until the force is around 2000. Around 10,000 it flies forward, but at 2,000 it just wobbles sideways???

I added a “lookAt” script to the camera so it will always face the object I am working on, simple public transform Target Manually dragged object into target in editor In Update: LookAt(target)

This is the only code

I then copy pasted the object a few times so I could view how they behaved from different directions.

The objects that I haven’t modified now bounce up and down and rotate until they flip on to their back.

The objects were not changed, I merely added duplicates. Some I rotated 90 degrees.

I removed the duplicates. The one remaining still bounces and tries to flip on to its back but doesn’t. Again, all I did as remove the duplicates.

I should note, I am not pressing anything, the wheels are just randomly changing behaviour while I am watching the screen scratching my head.

Rotating the object back to its original orientation stopped the bouncing, but doesn’t explain why, nor does it explain why having multiple objects not touching eachother, with no related code and no hierarchical relationship changed their behaviour.

I also rotated it back to second position while it was running, no problem. Stopped it. Rotated it, ran it, starts bouncing again.

It starts in the air so it’s not colliding with anything, and I emphasise no code is running on the object.

enter image description here

enter image description here

enter image description here

I still want to figure out how to get this to work consistently, as I’ve got other projects with similar problems. Adding multiple versions of same object, or following same process on different objects and getting different results every time. Sometimes it’s nice, a simple object with wheels the player can push or another object can pull. Other times it does random flips, different on every load. Other times it’s almost unmovable where I’ll add insanely high force of like 20,000, and it won’t budge even though its mass is only 250-750. I’ve also had issues where it floats , slowly tilts to one side instead of bouncing, sinks into floor (again duplicate objects behaving differently) or refuses to move until I manually lift and drop it after scene loads. I thought my scene might have too many factors interfering so I built this simple project from scratch and I think it’s just wheel colliders being super unreliable, am I missing something?

Tldr;

Can anyone explain why adding whee colliders to a plain cube with a rigid body, is producing random changes in behaviour, based on unrelated changes to scene, such as orientation of cube or how many cubes are in the scene?

0

There are 0 best solutions below