- Home /
Flickering wheel colliders
Simple enough to describe but baffling. I originally had a car with 4 wheels. It's a side-on trials-style game. It all works and is actually online to play. The wheels have wheel colliders.
However, when the car freefalls for more than about three seconds AND if the car is more or less horizontal (so it would land right-side up) the wheels start flickering up and down. The range they flicker goes from their most 'depressed' position (or 'the highest point of the suspension') to the lowest. Really fast, from one frame to the next. It was so distracting that, after weeks of fruitless tinkering, I turned it into a hovercraft (simply disabled the tyre mesh renderers but kept all the physics in place since they were working fine apart from the flickering).
Has anyone encountered this before? I'd prefer to have tyres on my vehicle despite the hover effect looking cool.
EDIT by 'online to play' what I meant to say was 'it's playable in web browser right now.' But I won't go plugging it as it's sort of an alpha and I don't want to start advertising on unity answers lol.
did you ever resolve this issue? struggling with this exact same issue right now.
Sadly not, it's still a hovercraft! I have a feeling it might work in the newer versions of Unity since some huge changes have been made but I'll have to dig around for the project file. What version are you using right now? And to clarify - the wheels are physically moving rather than flickering on/off?
Dang! I'm using the newest version of unity and it still happens. I basically have the same problem you described-- the wheels flicker up and down very quickly when it's in freefall (with the car more or less horizontal like you said). I've been playing with the values of the wheel colliders for so long now, but to no avail. I had an unrealistically scaled up (5x scaled) version of the car (that I made as a shortcut for dealing with a different problem I had) that didn't seem to have any flickering issue whatsoever. However, I needed to scale the car back down again so that it would behave more realistically with the physics/gravity, and the flickering problem returned. furthermore, my car is now having significant problems hitting jumps without the car losing traction on the jump and going into an off axis spin. let me know if you find anymore insight into this problem, or the general functionality of wheel colliders and their relationship to the car physics. thanks!
I know this is sort of the wrong way round since I'm the OP and you're the one commenting but you at least have easy access to your project :)
Have you checked the mass for the wheels? It's a long shot but I was recently doing some work on a ponytail with bones and rigidbodies using character joints. I noticed they were going all over the place when they were twisted too much in playback, flickering this way and that. So I looked around and somehow the mass of the RB's had been reduced to 0.01 yet they were still acting like they had more substantial weight. I Changed them back to 1 and it fixed them.
This bit is just an observation: I Was playing plants vs zombies on xbox one last night (the third person shooter version). Upon starting the game all the human players fell through the bottom of the world and dropped into oblivion forever. As my character dropped it eventually started flickering up and down on the screen just like our wheels! I thought it was oddly similar so it made me wonder if this was a general physics based issue that cleverer people than me know happens a lot with dropping objects in physics engines.
Hope some of that sparks someone elses imagination and they realise what's going on :)
yeah I messed around with the mass of the wheels, and it didn't really affect anything. Currently using a mass of 1. I also messed around with the mass of the Rigidbody associated with the car, and no difference also. I really have no clue why it isn't working with this version when it seemed to be fine when the car was the size of a house haha. I'm also frustrated that the handling going off jumps is severely worse than it was with the big car-- right when it first hits the jump, the spring reacts too violently and makes the car not go off the jump straight. I've tried varying every value in the wheel colliders (trying both isolating each variable and also changing multiple variables at once). I think the flickering is ultimately a sign of instability in the physics simulation itself, and I'm pretty much out of options for things to change to try and fix it. Really hope someone from the Unity $$anonymous$$m could take a look at this issue and respond to us.
Answer by sandhillceltic · Aug 22, 2013 at 01:59 AM
What is your texture type? I had the same problem. Try changing the wheel color to transparent, even if the texture is not. Worked for me. Good luck :)
Answer by aalstes · Oct 07, 2014 at 07:28 PM
I had a flickering problem and solved it by using WheelCollider.GetGroundHit instead of Physics.Raycast. The commented-out code caused flickering:
// RaycastHit hit;
WheelHit hit;
Vector3 wheelPos;
//if (Physics.Raycast(transform.position, -transform.up, out hit,wheelCollider.radius+wheelCollider.suspensionDistance) ){
// wheelPos = hit.point+transform.up * wheelCollider.radius;
// wheelTransform.position = wheelPos;
// airborne = false;
//}
if (wheelCollider.GetGroundHit(out hit))
{
// Code from http://answers.unity3d.com/questions/13180/using-wheel-colliders.html
wheelPos = wheelTransform.localPosition;
wheelPos.y -= Vector3.Dot(wheelTransform.position - hit.point, transform.up) - wheelCollider.radius;
wheelTransform.localPosition = wheelPos;
airborne = false;
}
else {
// We're airborne. If we were already airborne in the previous frame, do nothing.
if (!airborne)
{
wheelPos = transform.position - transform.up * wheelCollider.suspensionDistance;
wheelTransform.position = wheelPos;
}
airborne = true;
}
The problem with this is testing with Unity5.1.2 GetGroundHit returns an incorrect hit.point value. Seems like its one frame behind making wheel offsets impossible to do correctly.