Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Physic Car Setup Tool

Discussion in 'Made With Unity' started by ikiman, Jun 24, 2009.

  1. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    Hi all,

    Many people asked me about the Physic Car tutorial and I must say I'm writing now, but I have little time, so be patient.

    In the meantime I've made a kind of tool for a physic car setup, It has sliders for more interesting parameters in two sections:

    Car section to the left with sliders for suspension, tyre stiffness, power engine, etc.

    AI section to the right with thrust and driving sensitivity.

    Also there are three cameras, a classic follow camera (by default), an on board camera and an interactive camera. When you select this last one, the offset parameters appear under the AI section.

    I think this is a good way to know how different parameters affect car behavior. Please try carefully at first and look for reactions.

    You can drive and leave the track pressing "i" to test in an off-road fashion.

    The values exposed next to the sliders are real world values, it means you can use what you see in your code.

    The final tutorial will have explanations on those parameters but will not include the interactive part (sliders) nor the AI, just the basic script where you can tweak the values.

    The car model is a De Lorean I found for free in Turbosquid, if anyone knows any problem with that please tell me and I'll change.
    The car is at real scale 4,2 metter long.
    The track is based in the Infineon Raceway.

    http://3dnemo.com/games/release/056_CarTool.html

    Edit:

    Controls are:

    "c" change camera
    "i" AI on/off
    "Space" brake
    "r" return to the track


    Please tell me if you find this interesting to continue improving.

    Thank you and enjoy.
     

    Attached Files:

  2. theinfomercial

    theinfomercial

    Joined:
    Sep 9, 2008
    Posts:
    1,000
    Neat stuff you have. I'll try it later. :wink:

    If I got that car up to 88 mph, would it disappear in a flash of light. :D
     
  3. emergki

    emergki

    Joined:
    Oct 15, 2007
    Posts:
    421
    Very Nice...

    I can't wait for the tutorial :D
     
  4. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Interesting, I was hoping that the default settings would be drivable right off the bat and when I cranked up the power and all it seemed to drive more like a SeaDoo/Jet Ski than a car.


    Nice! But you left out some of the best parts, notably the elevation changes as that makes it such a fun track. Oh, and you're having us run it backwards by default. :) I know this as I've spent a fair amount of time in the saddle at "Sears Point" (I won't call it Infineon! :) ) and I worked there for over a year in high school (having grown up in Sonoma).

    photo proof

    (cresting the hill in turn 2, exiting turn 9)

    </off-topic bragging>
     
  5. Vern_Shurtz

    Vern_Shurtz

    Joined:
    Mar 6, 2009
    Posts:
    264
    Very Interesting!!!! :D

    Is the scripting JS or C#. Since JCar is out and is in C# it would be nice to see a good Car physics script/tutorial in JS.

    Also are you using the Unity Wheel Colliders along with there friction curve?
     
  6. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    • theinfomercial wrote

      If I got that car up to 88 mph, would it disappear in a flash of light.

    Not yet, I have the flux capacitor still under development. :)

    • HiggyB wrote

      Interesting, I was hoping that the default settings would be drivable right off the bat and when I cranked up the power and all it seemed to drive more like a SeaDoo/Jet Ski than a car.

    I changed default settings, it doesn't looks like a SeaDoo anymore (at least I hope so, but Tom, it's your wheel colliders :) ). Also I added some brake zones and now the lap time is in the 1 min 15 sec range.

    • Nice! But you left out some of the best parts, notably the elevation changes as that makes it such a fun track.

    Unfortunately I didn't have that info, I'll work it a little more.

    • Oh, and you're having us run it backwards by default. I know this as I've spent a fair amount of time in the saddle at "Sears Point" (I won't call it Infineon! )

    Corrected the run direction, and sorry, all references pointed me to "Infineon" as the right name but, from now on, it will be "Sears Point".

    • Vern_S

      Is the scripting JS or C#. Since JCar is out and is in C# it would be nice to see a good Car physics script/tutorial in JS.

      Also are you using the Unity Wheel Colliders along with there friction curve?

    The script is in JavaScript, and yes, I'm using wheel colliders, but I'm not tweaking the friction curve as I found unexpected behaviors, I'll try to understand deeply that part, but it requires a lot of time and test, so that values are by default.
     
  7. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    FYI, Infineon Raceway is its proper and correct name, I'm just being an old curmudgeon wanting to call it by the name used when I was a kid, Sears Point. So you were correct, I was just having fun... (as I was with the elevation bits too). It's just a track that I personally have a lot of history with so I tend to get chatty about it. :D

    Oh, and yeah, those wheel colliders... :p
     
  8. JeffAU

    JeffAU

    Joined:
    Mar 22, 2009
    Posts:
    387
    Heya ikiman,

    Very very nice!!

    This car feels like the most realistic handling I've seen so far in Unity....any chance of sliding/drifting though? It would be wonderful to get some drifting and fish tailing going on...on road and off road.

    Any idea of what you will charge for this? Timeframe?


    Cheers


    Jeff
     
  9. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    Updated webplayer with raceway modified. Now it looks a lot more like Infineon Raceway (formerly known as Sears Point Raceway).

    Added some in screen controls like sound volume and some graphic options.

    Enjoy.
     

    Attached Files:

  10. Cu3e

    Cu3e

    Joined:
    Oct 27, 2008
    Posts:
    63
    Pretty impressive! I like the skidmarks :)

    Two questions:

    1. Is it possible to keep the throttle on, even if the car starts to oversteer? It feels like limites slip differential kicking in or something... I want nice oversteer through the corners :D

    2. Is it possible to turn off the force that keeps the car on it wheels and prevents from rolling over?

    Other that those things, feels superb! :p
     
  11. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    Hi Tri3,

    I'm still working on it and some drift is a popular claim, but it's not a part of the wheel colliders design on it's own, so it must be made by code tweaking carefully front and rear wheels friction. I will include that soon.

    About the force that prevents to rolling over, there is no such thing, try with the side friction slider and you will see. But you are right in part, to make the car more steady, the rigidbody angular drag is in high value (2). To simulate a crash with a lot of car flip, that must be changed on the fly along with the center of gravity. Also I'm working on that part.

    And thanks for the comments.
     
  12. Jon

    Jon

    Joined:
    Aug 2, 2008
    Posts:
    65
  13. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    Hi Jon,

    Yes, it is when you go to max power engine (as I can see in your screenshot), think that's not a finished setup nor a game so still needs some adjustments for things like extreme collisions.

    The webplayer is intended mainly to see what happens when you change physic parameters in the car using wheel colliders, so you can adjust values for your own development.

    But, as I said, I'll improve it as I receive feedback from the community.
     
  14. destroyerhst

    destroyerhst

    Joined:
    May 5, 2009
    Posts:
    20
    Any chance to download ?
     
  15. Vern_Shurtz

    Vern_Shurtz

    Joined:
    Mar 6, 2009
    Posts:
    264
    By code tweaking wheel friction are you referring to adjusting slip, value, and stiffness? Basically changing the shape of the wheel friction curve depending on factors such as speed, steering angle, directional magnitude, etc.

    I am working on a set up where I can adjust every input of forward and sideways friction based off of the above factors and I am seeing much better results by being able to alter the wheel friction curve to better suite the situation.

    I do not believe a single setting is capable of fulfilling all situations and I think that is where most people get frustrated using the Wheel Collider.

    I started a discussion a few weeks ago on the wheel collider if anyone would like to chime in.


    http://forum.unity3d.com/viewtopic.php?t=26405
     
  16. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    Hi Vern_S,

    Yes I talk to adjust dinamically the stiffness factor (forward and sideways) depending mainly on speed and steer.

    At first I was affraid on messing up the physic engine with that, but I found little problems on doing it, you can see some of that in action in my page, try Sprint Cars demo that features a controlled sliding in turns.

    But I think there is a misconception with a car setup. In real world cars are designed for a specific task so a Nascar has nothing to do off road.

    What I found is people try to setup an all-road car capable of great stability at high speed but with high and soft suspension and with lovely drifting in turns, that's not possible,

    By the moment I can say wheel colliders do the job very well, but a lot of research must be done.
     
  17. jojimbo

    jojimbo

    Joined:
    Jun 25, 2009
    Posts:
    37
    I love it,the update you did on the track area textures in that pic looks really great.It reminds me of grand turismo,yeessss,hehe.
    any chance of changing the camera so you have multiple angles like bumper,driver etc?
     
  18. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    Hi jojimbo,

    Press "c" twice and you are in interactive camera mode, move the camera where you want with the sliders in the lower right corner.

    And don't forget to press "i" if you want to drive.
     
  19. Armagon

    Armagon

    Joined:
    May 29, 2009
    Posts:
    246
    Will this be available for download or sale? If for sale, an affordable price?
     
  20. the_gnoblin

    the_gnoblin

    Joined:
    Jan 10, 2009
    Posts:
    722
    Hello, ikiman!

    I have a question to the vehicle-Guru:
    When I use wheelcolliders, wheels fall through obstacles - which is not nice (if I drive on a pile of rocks - only the middle-part of the wheel collides). Could you give any advice how to fix that?
    Maybe using 2 wheel colliders for each wheel (on the left side and on the right side) or attaching a spring on each side of the wheel? Thanks).
     
  21. wannabeartist

    wannabeartist

    Joined:
    Jun 20, 2009
    Posts:
    272
    Great work!

    Really looking forward to your tutorial! Despite of searching I haven't really found satisfactory car script (or instructions to make one) yet.
     
  22. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    Hi all,

    I'm looking for some collaboration.

    I have the demo project (with the car script included) almost finished. It is slightly different from the Setup Tool, it lacks the AI, the GUI controls, and some textures have changed for copyright matters, but the scenery is the same and all vars are there in the script and exposed in the editor.

    I cannot say the same for the tutorial because is much more difficult to me and time consuming to write in english that I must translate from spanish, some collaboration on that would be good too.

    What I need now is some testers before publishing in the forum to look for bugs, propose some code improvements (as I'm not a programmer I think the code is not so nice as it can be), and in general any change to make it easier to understand and manage.

    This is the deal:

    If you tried to make a car setup (physic or not) with Unity and you have a demo (preferably webplayer), send me a PM and I'll evaluate your demo, and if approved, I'll send you the project.

    Please don't hurt me if you are not approved, I'm interested in people that made some effort in understanding the car setup and can contribute with something interesting for all.

    You don't need to have a beautiful race track or car, only a car running and in some manner drivable, so don't be shy.

    Thank you
     
  23. wannabeartist

    wannabeartist

    Joined:
    Jun 20, 2009
    Posts:
    272
    I guess you mean home-made setups? I have tried a bunch with my model, but the code is not mine - setups like JCar for example.
     
  24. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    Hi wannabeArtist,

    Maybe I didn't explained clearly.

    Any car setup is valid, with the Jcar script or any, you don't need to have your own code but your own setup (a Unity demo project like Vehicle Example is not valid, so don't show me a webplayer with that).

    Only show me that you are really interested and that you tried.
     
  25. midknight

    midknight

    Joined:
    Mar 24, 2009
    Posts:
    19
    This looks very educational.. have you released this project yet?

     
  26. ikiman

    ikiman

    Joined:
    Feb 19, 2008
    Posts:
    117
    @midknight

    At this moment I'm involved in a more ambitious project, the "New Unity Car Tutorial / GTA4 Vehicle Replica " look for it in "Collaboration" forum.

    My last entry included this video:

    http://nemdrive.com/Demos/C6R/video.html

    And I'm working hard on it.
     
  27. rstanmoy

    rstanmoy

    Joined:
    Dec 31, 2010
    Posts:
    1
    hi everyone

    can anyone help me out?
    am a computer science student and working on a car racing game project but cant understand from where to start. the game must be 3d. i need help to start. i need a full code and designing tutorial using c# with the designing tool. that will be enough if i get a simple tutorial on just making a car and a simple track and then run it over the track. i want to use XNA game studio as well.

    please anyone help me to do this so.

    waiting for everyone kind information and help.

    thanks
     
  28. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Since you're using XNA why don't you try posting on their forums and see if anyone over there will do your school-work for you?