- Home /
The question is answered, right answer was accepted
Unity 5 - good parameters for vehicle
I have a problem with colliders. First - stats: Car:
mass= 1000
motor torque= 5000
steer angle = 25
wheel colliders:
mass= 25
radius= 0.5
wheel damping rate=0.25
suspension distance = 0.5
force app point distance=0.1
Suspension spring
Spring = 35000
Damper = 3500
Target position = 0.1
Forward friction
Extremum slip:0.5
Extremum value:1
Asymptote slip: 0.8
Asymptote value:0.5
Stiffness:1
Sideways friction
Extremum slip:0.2
Extremum value:1
Asymptote slip: 0.75
Asymptote value:1
Stiffness:1
The problem is sliping. My car wheels rotating to infinite, but acceleration is about ~2m/s I want to have a car with ~100% friction, almost no sliping, for high speed and acceleration. I tried to handle with every param, but I cannot do it work correctly. I know there is a car in standard assets, but this code isn't looking good for me and I want to do in other, standard way. Is there a possibilty, without a hacks in code, to work those wheels like real one? If somebody have good model, with parameters, I would be pleased for used statistics. What I did wrong (parameters, ground?)
Answer by DiegoSLTS · Aug 11, 2016 at 05:25 PM
Setting up a usable car is really tricky, The setup also depends on the position and size of wheels and the car body, and if you're just reading the Unity manual you'll miss a really important thing: Stabilizer bars
In a game I made in Unity 5.1.2 I have...
Car
Mass: 1500
Drag: 0
Angular drag: 0.05
Max motor torque: 400
Max steering angle: 10
Wheels
Mass: 20
Radius: 0.23
Wheel damping rate: 0.25
Suspension distance: 0.1
Force app... : 0
Center: 0,0,0
Suspension spring Spring: 100000 Damper: 2000 Target position: 0.5
Forward and Sideway friction 1 in everything except Stiffness, with 5
Also, for the stabilizer bars: Anti roll: 10000
It's very slow, and car is shaking. I set 400 torque for 2 back wheels. Acc it's about ~2/s and big sliping. $$anonymous$$aybe it's about ground material (no material). Simple solution it's to increase timestep and reduce gravity. Do your car is fast enough?
In my game the car is on a mountain so it gains some speed because of gravity. Is fast for what we wanted to do, which was a billy cart, it's not supposed to gain speed like a real fast car, but we do force some acceleration in case the car gets stuck at something. At some point it was too fast so we also apply a break force after reaching a certain speed.
I think (it's an old project) the shaking was related to the "substep" used by the physics engine. The magic numbers for us were:
anyWheelCollider.ConfigureVehicleSubsteps(5f,12,15);
It says "anyWheelCollider" because you only need to set the substep once, but it's not a static method so you need an instance of WheelCollider to change it's value.
Anyway, it's a pain to set this things up, most of the times it felt like I was trying random values for everything. If you research a lot you'll find a video of someone that "fixed" his car physics after upgrading to Unity 5 by setting the car weight to an unrealistic low weight (like going from tons to less than 100 kilograms). It takes time but at some point you'll find some magic numbers for your game.
This was the game: https://www.youtube.com/watch?v=Hjii7E_zQyA It's not on the store anymore but you can see the game running at 0:30.
I do like in https://www.youtube.com/watch?v=HT15SlYr2Pw. You are right, it was a mass problem. $$anonymous$$y stats for now (if somebody would like to know):
$$anonymous$$ass: 20
Drag: 0.1
Angular drag: 0.05
$$anonymous$$ax motor torque: 100
$$anonymous$$ax steering angle: 10
Wheels
$$anonymous$$ass: 10
Radius: 0.4
Wheel damping rate: 0.25
Suspension distance: 0.1
Force app... : 0
Center: 0,0,0
Suspension spring Spring: 1200 Damper: 50 Target position: 0.6
Forward and Sideway friction 1 in everything except Stiffness, with 5
I have sliping ~0.05 and problems with car rolling on turns, but it's good start to improve steering. Thanks for help!
Follow this Question
Related Questions
fast forward physic vehicles 0 Answers
Vehicle programming source 5 Answers
Need for speed like physics using Edy's vehicle physics? 1 Answer
Strange car beahaviour 0 Answers
How can i import a new car in edy's vehicle physics? 2 Answers