# Me attempting to achieve some semi realistic vehicle physics, with wheel colliders.

Hello there, i was messing around with unitys wheel collider for a week now. Wher ever i read, mostly i get bad feedback about wheel colliders, but i think that physx wheel colliders are actually pretty good, they only need a little extra script for dynamic friction (i also started a thread in the scripting section, to see how many people know various methods for dynamic friction, but without succsess).

So what i did here, is i took Andrews car tutorial (http://www.gotow.net/andrew/blog/?page_id=78, thank you!)
and started tweaking it, switched the original track to a custom terrain one, added differential ratio, few visual effects(projector, light flares etc.), some simplyfied scripts to change friction suspension easly in one inspector and finally i also added antirollbars from edy’s tutorial.
Oh yes i was also busy updating the real script, so i did not update the ai one, so the waypoints exist and the script is also there but its “outdated”…

So at wheel friction part, i tryed to use as lifelike values as possible, and i hope that unity/physx reads them also that way.
Heres what i use for longitudinal lateral friction curves:

``````var ForwardExtremumSlip : float = 10;//slip ratio where the tire grips at most;
var ForwardExtremumValue : float = 100;//100% of the available friction is used;
var ForwardAsymptoteSlip : float = 100;//slip ratio where the curve has no grip;
var ForwardAsymptoteValue : float = 0;//0% of the friction available is used;
var ForwardStiffness : float = 1.0;

var SidewaysExtremumSlip : float = 6;//slip angle where the tire grips at most;
var SidewaysExtremumValue : float = 100;//100% of the available friction is used;
var SidewaysAsymptoteSlip : float = 40;//slip angle where the curve has minimal grip;
var SidewaysAsymptoteValue : float = 1;//1% of the available friction is used;
var SidewaysStiffness : float = 2.0;// 2 just worked better...
``````

I’ll explain my theory abit, well car wheels have logical parameters for movement (in longitudinal lateral ways)
they are slip ratios and slip angles. So i tryed to use slip angle and slip ratio parameters to achieve my friction results.
The only unrealistic thing i made here, is that I made the curves more like simple peaks, the curves start from 0 and raise a griping position and after that they decrease to 0 or 1.
In real life this does not happen, in real life both forward and sideways frictions are combined and cut by longitudinal or lateral movement, for this kind of simulation we need a dynamic friction script (withc i was talking earlyer)
Since i did not manage to create a script that would do such thing, I faked the curves by simply decreasing the curves to 0 or 1 (minimal grip). Its not a realistic solution, but It seems to me that these “mountain” values work quite well actually.

Obviously some have discovered this before, but i did not find any reference to this, so i decided to share my knowledge.

The car model i found from the internet, and i dont know who the author is, anyway it’s only a placeholder to visualise a vehicle …obviously.

NOTE
There are alot of other things that need to be fixed (engine torque, gearbox etc.), but i was concentrating on the wheel friction enjoyable handling!

Image:

UnityPackage:

And finally, if you make any changes to it please share your knowledge!

Hey Ravel,

I’m very very impressed.

This really does handle very well and interacts with the terrain beautifully.

Are you able to tweek it a little more so that at high speeds the steering is less sensitive? It seems to turn so sharply at high speeds that you lose speed and the car slides out.

Also it would be great to get a little move slow speed wheel spin for burnouts and fishtails.

I’ve been following every Unity vehicle project for the past couple of years and I think what you have here could be the best handling vehicle I’ve driven. Sure some may say that others are more realistic in some areas but your project is just what I need - a fun, fast vehicle which drifts, is great at low and high speeds and interacts perfectly with the ground without any strange bouncing or glitching at high speed.

A BIG Congrats!!!

If you make any changes please let me know - I’d hate to miss them.

JeffAU

pulling the steerangle down from 35 to 20 feels great.

After driving for a bit longer, I love this car twice as much as I did when writing my comment above.

Are the tail-lights just lights?

Thanks JeffAU, seting the sideways asymptote slip to 30 and value to 10 should make it harder to drift/slide at higher speeds, if i remember correctly haha. For burnouts, i think we need that dynamic friction script, because when a wheel does a burnout, the longitudinalfriction is higher than lateral friction, in pacejka formula this is done by combining the pacejka. Anyway i was aiming at fun but realistic physics, like in gta IV or racedriver grid. About spinouts, in real life, if you steer with such angles in a high speed, the car does one of two things, the car spins out or flips, since this is more like a sports car, it doesnt flip that easly, it simply spins out.

And yes it’s a nice car in real life to haha.

carking1996, the tail-lights are flares only.

Nice job. Btw, what shaders are you using on the car? It looks awesome!

I use the standard unity reflective bump/specular shader
I just didnt go nuts over the setup …as a lot of people seem to set everything to the max, maximum isnt always a good solution haha.

What reflective map did you use? Can you send it to me? Or, post it here? I love it!!

Uhm i added the unity package, i think it extracted all of the media to your hardrive?

Edit: well i am new to unity, i dont know if i packed it correctly, but JeffAU played it, so i think the media should be stored on your hard drive, in the project that you opened it in.

hmmm … having trouble getting the AI script working. Hs anyone managed to get it working yet?

if you want i can make it work after i have changed the engine part(if im going to do that haha)

Yeah Got AI working again. I just grabbed your new Player script and merged in the waypoint code from the old script.

Hello,
I know you haven’t been active for a while but I just wanted to say this project has made my day Well my app

It’s simple and down to the necessity and thats how i like it easy to add on till the cows come home

Thank you thank you thank you!
Daniel

hey can I ask where you got the car model from ?? I really like it…