Home Technical Talk

Issue modeling a racing track in 3DS Max for Unity

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

  • monster
    Options
    Offline / Send Message
    monster polycounter
    There are so many things that could go wrong with physics settings, scales, and materials.

    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.
  • Brendan
    Options
    Offline / Send Message
    Brendan polycounter lvl 8
    Firstly, post wires. While soft normals and smoothing groups look nice and pretty visually, physics relies both on raw vertex density and CORRECT triangulation.

    phystest.png?w=600
    [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.
  • derkoi
    Options
    Offline / Send Message
    Thanks for the replies.
    monster wrote: »
    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.

    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. :(

    Brendan wrote: »
    Firstly, post wires. While soft normals and smoothing groups look nice and pretty visually, physics relies both on raw vertex density and CORRECT triangulation.

    Here's a shot of the wires, however I've tried that many different variations :poly142:

    Screen-Shot-2012-11-07-at-09.20.33.png

    So do you think i should try adding a single edge down the center & reverse the triangulation? How do i reverse the triangulation?

    Brendan wrote: »
    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.

    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.

    Screen-Shot-2012-11-06-at-13.58.27.png
  • Brendan
    Options
    Offline / Send Message
    Brendan polycounter lvl 8
    Yep, try adding an edge loop (or maybe a few of them, no need to be perfectly accurate while there's the undo button available) and test. If it helps, try it out in different positions (left/right) and different numbers of them. Once you've got it working really nicely, see if you can get away with removing every second (already existing) edge segment. If 2 square quads work better than 2 thin ones, then that'd a good thing anyway.

    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.
  • Steppenwolf
    Options
    Offline / Send Message
    Steppenwolf polycounter lvl 15
    Problem could be that you only use one ring of polies for the track, essentialy creating a saw pattern that the car rides over, especially in up-/downhill corners . Here is an example of how i used to model tracks for rFactor:

    SQlNu.jpg

    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.
  • derkoi
    Options
    Offline / Send Message
    Thanks for the replies, I'll make some changes & see what happens. I didn't realise it would be so touch & go regarding the geometry of a track, makes me think it's going to take me a while longer to make the tracks.

    Brendan, it seems the Anti roll values are in Nm as taken from the documentation site
    • Anti Roll Bar Front and Rear This value specifies the strength of the anti roll bar. Its used to damper the weight transfer in curves with soft springs. Typical values varies depending on the power and weight of the car. Values are in Nm. For a powerful sport car typical value is 20000 Nm. For a less powerful and lightweight car typical value is 4000 Nm. Higher front value produces more understeer, higher rear value produces more oversteer.
  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    try to split your track mesh collider to smaller parts. smooth sphere collision should be on. watch for scale of things. visually check triangulation not in max but in unity cause unity uses some built in optimisation when importing geometry like triangle strip generation etc..
    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.
  • derkoi
    Options
    Offline / Send Message
    Thank you all for your help! It seems as though the problem is sorted!

    Firstly I made a collision mesh based on what you were suggesting:

    Screen-Shot-2012-11-07-at-16.13.11.png

    When I tested this however, it still made no difference.

    So going by Brendan's suggestions, I applied the following settings to my vehicle:

    Screen-Shot-2012-11-07-at-16.14.01.png

    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!
  • Brendan
    Options
    Offline / Send Message
    Brendan polycounter lvl 8
    Well it looks like you've got a lot of the problem sorted out now.

    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.
  • derkoi
    Options
    Offline / Send Message
    Thanks, I'll download that and take a look, just what I need. :)
  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    If you are using collider as on last picture.. green wireframe. Please get rid of that dense sidewalks geo unless you really need it for something special :) Only one loop is enough there.
  • derkoi
    Options
    Offline / Send Message
    cupsster wrote: »
    If you are using collider as on last picture.. green wireframe. Please get rid of that dense sidewalks geo unless you really need it for something special :) Only one loop is enough there.

    Yeah I noticed that, it's just the way 3DS Max did it with the lofting tool, i guess I should do it manually. :)
  • cupsster
    Options
    Offline / Send Message
    cupsster polycounter lvl 11
    Yep. Before export always check your models. Either STL Check or other. For colliders check shilouette and redundant triangles. Less triangles in collider = quicker and more smooth physics in Unity [not always case tho].
  • derkoi
    Options
    Offline / Send Message
    Thanks, will keep that in mind :)
  • pendtoni
    Options
    Offline / Send Message
    Hi derkoi, just wondering if you could post up a step by step tutorial on how you made your track through splines and lofting, as I'm trying to create a track myself but I'm experiencing problems with the banked corners and the scale of track. It's for a group project at university in which we are trying to create a point to point driving game in UDK. Cheers
Sign In or Register to comment.