For the last couple of weeks I have been playing around with the wheel colliders with relative success.
My current project has a tank that drives around with terrain-conforming wheels etc etc.
Everything works pretty well but one problem I just can’t seem to find a solution to.
When my tank is heading up steep slopes it seems to get bursts of torque - way more than I have set as the limit for each wheel (200rpm). These bursts can go up to 400rpm or greater and send my normally sluggish tank rocketing up steep inclines. While this is amusing for the first hour or so - here I am a few days later scratching my head and become suitably annoyed.
I had one problem quite similar with my car where if my car reached a particular speed it’s unstoppable, a rocket I might add! but does your tank get normal when it return on the flat ground? is the steep downwards or up? it must be something with calculations. You can provide your piece of code and Community may help…
Try:
var throttle : float = Input.GetAxis(“Verticle”);
While it actually works to a degree it doesn’t solve the problem entirely.
While I clamp the RPM and velocity successfully, the problem is RPM reaches that max velocity too fast. So while I don’t rocket up slopes super fast anymore there is still some kind of “lurching” effect as the wheel RPMs go from zero to maximum in a split second.
When I am going downhill or on level slopes everything is fine - it is only really steep inclines. It seems to be especially evident when one or several wheels are suspended in mid-air and then make contact with the ground again…
Maybe I should just make it a game mechanic? haha jk
I have the same problem, while I havnt tried to fix it yet, I believe the cause is the torque max’s out while the wheel is off the ground offering no resistance.
I suspect the fix will be to cut all torque if the wheel is off the ground.
I think the problem with this would be that we are limiting RPM to a set number.
I can’t believe there are so little solutions to this. I guess wheelcolliders just aren’t as popular.
I might have to rework my game because I am making a game with a buggy that is off roading. Lots of slopes, and right now I am just shooting off of slopes. Not fun.
sure, but its an arbitrary test number for verification purposes… 100 probably wouldnt be the final number, it would be whatever number feels right to you.
The wheel collider is behaving exactly as youve told it… if you let it spin up really fast, and its slip isnt set correctly its gonna power the car forward when it makes contact.
at some point ill experiment with it… have you looked at the Unity car tutorial, see if theres suffers teh same problem?
I downloaded it this morning but haven’t really gotten a chance to play with it. I’ll take a look later tonight.
BTW - do you have a good way of determining the angle of slope a car is currently on? I am using a Unity terrain and would like to know the angle of slope.
I took a quick video to show exactly what the problem is. Notice how it speeds up going up hills.
BTW I am looking at the Unity car tutorial in the asset store and I don’t see any wheelcollider objects in that car. So I think they are using their own system and no wheelcolliders.
I would just like to update, I looked at Unity’s car tutorial. Instead of using wheelcollider.motorTorque, they just add force to the rigidbody. I changed my script as well to work similarly, and it works great! No more zooming up inclines…
After looking at the Unity 2014 assets… Man they made it really complicated. Sure they are using wheel colliders but making sense of the code is so much more complicated.
More testing and what I found is: Even in Unity 2014 Beta assets where they are using WheelColliders, the cars zoom up the hills. So it must be some kind of issue with the wheel colliders!
seems counter intuitive to offer a tutorial with wheel colliders that adds force to the rigidbody… just screams we cant get them to work properly either, so we wont bother.
see what U5 brings I guess.
might have to try and figure this problem out myself when I get some time