I hope someone here can help as the issue I have is a game breaker.
I've been working on a racing game in Unity, where the tracks are smooth with hills and banked corners, nothing too out of the ordinary.
I'm modeling the tracks in 3DS Max using the lofting technique & I'm very happy with the visual results.
However, when the tracks are in the game and being driven on, the car (powered by the UnityCar 2.0 package) bounces wherever there's a hill on the track. Like it's bumping off the geometry. Ok I thought, i need to increase the polycount, but that made very little difference. I've tried all different smoothing methods, a separate collider mesh really high poly count, setting smooth sphere collisions in Unity and nothing seems to change the way the car behaves.
I'm lost for what else to try, other games have smooth running cars so I know it's something I'm doing. Could it be my export settings? I'm exporting from Max to FBX format if that makes a difference?
Here's a video of what's happening, however in this video it's not as bad as it gets.
[ame="
http://www.youtube.com/watch?v=p394Z-vO3mU"]Bumpy Track - YouTube[/ame]
Any suggestions please?
Replies
I would create a perfectly flat section of track and test that. Also test the tracks that come with UnityCar2.0.
Since Unity car is a paid extension it may be fastest to contact the developer.
[EDIT: OH CHRIST I GOT THE BOTTOM PICTURES IN THE WRONG ORDER]
As you can see, reversing the triangulation has a MASSIVE effect on what the physics engine has to deal with. This problem is exacerbated by the track being only one 'quad' wide. As you can see, one will cause a loss of traction laterally, and the other longitudinally, as the normals diverge more in certain places. Fucked up triangulation can easily put to waste an entire subdivision level.
I see a lot of people have this problem and immediately go and add more lateral edges to little or no effect, whereas a single edge running down the center of the track can sometimes be all that it takes to fix it.
Secondly, slap whoever calibrated the suspension. It looks like you're going for RC-car inspired physics? For what it's worth, they've done a good job of replicating what an RC car often does going over a crest.
A reconsidering of suspension is in order; remember, it's something that is used to consistently maximize traction through maintaining contact patch size and loading.
What's happening at 0:6 in your video is that the rear of the vehicle is either touching the ground or the limits of the suspension travel, and because the force of the road is no longer being absorbed by the spring, it's going straight into the rear of the chassis. Ergo, the rear loses contact with the road over the crest like a bobsled off a jump.
There's several options you could go for here, and each will produce different handling characteristics for the car. Keep in mind a major change from one should also include minor changes from the other.
Spring Rates and Mass:
These should help with the bottoming out; increase the mass of the vehicle to 200%, the spring rate to 300%. While the track might be polygonal, the trajectory of the car doesn't have to be. Use the extra mass to drive those springs harder and you should be getting more action around the 30-70% wheel travel mark.
This can make the vehicle a bit more sluggish in most ways.
Dampers:
Another way to tackle the problem is to apply a counter-force to the spring so that it can't reach either fully extended or compressed as abruptly. Increase the damping force significantly (try +50%, +100%, +150%, +200%, etc) until it goes from bouncing on the edges, to 'strangely smoother', then starts to get bouncier again. Set it at 75% between original and 'strangely smoother', then make much smaller spring and weight adjustments based on the above.
This can make the vehicle more agile or twitchy.
Either way, I'd highly recomend some sort of anti roll bar script. The old Unity car tutorial includes a decent script. This will also help deal with both the triangulation and the lateral forces of the vehicle; body roll (weight transfer) isn't fantastic for traction or control, but thankfully it's fairly easy to deal with. Include it, if it's not already part of Unitycar, then slowly increase it until you can notice changes. From that point, you'll need playtesters to give you outsite opinions.
I have tried a flat track, and the flat parts on my track work perfectly fine.
I also contacted the developer over Skype, he didn't know what the issue was & suggested I add one of his pre-built cars to try, it did the same thing as mine. I also thought it was a scale issue, resized everything but it's still the same.
Here's a shot of the wires, however I've tried that many different variations :poly142:
So do you think i should try adding a single edge down the center & reverse the triangulation? How do i reverse the triangulation?
That would be me, I've been playing around with the settings just to get something that handles pretty well, then I planned to go in and tweak & test, the player can also tweak the settings too, or at least that's the plan.
I'm not going for RC car physics with this one, they're just full size buggies that race on the moon, either on tracks or across the surface or a combination of the two. (I know the moon doesn't have the same gravity etc but it's not a simulation game it's a semi sim with arcade racer)
Here's a shot of the settings with Unity car, these are default which I've gone back to, in the hope of following your advice.
I'm not a max user, but this should help with triangulation:
http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-0196A023-116F-47F8-99E9-AF3CB52F302C.htm,topicNumber=d30e383184
For physics stuff, try taking the suspension rates to 60000, the bound and rebound to 6000, fast bound/rebound down to 0.2, suspension travel to 0.5. I take it the vehicle is almost always accelerating (foot on the gas)? If that's the case, move it forward a bit and up a tiny tiny bit.
I don't know the exact units that the antiroll are in, but I'm assuming that it's either 10000N/M/Wheel (which would be physically correct and apply a maximum of 20,000N/M against the outside wheel when fully-loaded using that example) or something else entirely (god only knows, roll bars and differentials usually get shat on when coded).
Also grab the rigidbody, increase mass a bit, and also turn up the angular drag. Both of those should show pretty immediate effects.
I'm not familiar with the tyre grip factors or the Unitycar competition tyres. Though, I imagine they could be use to re-tune the handling if my changes adversely affect it if need be.
Grey part is the track. White parts the surrounding, getting less detailed the further away from the track.
Of course there could be a lot of other reasons for your cars behaviour that don't have to do with the track model itself.
Brendan, it seems the Anti roll values are in Nm as taken from the documentation site
other than that check that forces you entered in your car setup are real and can also look for wheel collider setup [duno if it is raycasted or using wheel collider]
yaou can also look for collision maximum penetration distance in settings. this controls distance colliders can intersect before applying force to separate them.
last option would be to toy around with fixed step update time. also in settings.
Firstly I made a collision mesh based on what you were suggesting:
When I tested this however, it still made no difference.
So going by Brendan's suggestions, I applied the following settings to my vehicle:
Here's a video of the outcome!
[ame="http://www.youtube.com/watch?v=3kqqJN7AvXQ"]Lunar Grand Prix HD - Work in progress - YouTube[/ame]
So I just want to thank you guys for your help and advice, without it I'd still be struggling to get things this far!
One thing I can recommend to everyone doing physics is to have a copy of this:
http://www.inscale.cz/download/gtr_engineers_handbook.pdf
saved on your hard drive somewhere.
It does a fantastic job of briefly explaining a fair few of the aspects for vehicle physics. You won't have or need to use all of the variables (aerodynamics, advanced tyre simulation) in everything you do, but there's always going to be some overlap with what you've got to use.
Yeah I noticed that, it's just the way 3DS Max did it with the lofting tool, i guess I should do it manually.