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

Yes, I know another car demo...

Discussion in 'Made With Unity' started by jkreijkamp, Aug 16, 2008.

  1. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    Maybe I should have come up with something more original than a car demo, but I really wanted to find out how to use those wheelcolliders. Nevertheless please give it a go. The assets I used are mainly of an older game I made with Irrlicht before I saw the unity light, the car model is a modified freebee from turbosquid. Controls:
    icon upperleft corner: switch to fullscreen/back
    - arrows to steer, accelerate/decelerate
    - r to right the car when stuck/toppled over
    - d switch between 4wd to frontwheeldrive and backwheeldrive
    - g switch between manual and automatic gearbox
    - pageup/pagedown switch gears
    - space brake

    http://www.ctrl-j.com.au/pages/demo.html
    (besides the webplayer you can also download mac/win binaries from this page)

    If people are interested, I could make a smaller project file with source available for the car scripts. As it seems there are not many wheel collider car scripts publicly available. Mine is far from perfect, but at least it would be a start.

    So, what do you think?
     
  2. Obscurity

    Obscurity

    Joined:
    Nov 13, 2007
    Posts:
    203
  3. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    I get a lot of flickering onscreen when going fullscreen. Also even tho I go fullscreen, it is a very low res image which I see stretched to my full screen.
     
  4. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    What kind of mac/pc hardware do you use? Works perfectly with my ibook, mac book, compaq pc, and intel imac with Radeon X1600, although this one sometimes gives problems, but that is, I assume the buggy 3D driver apple still hasn't fixed (great if that happens to be your development platform for 3D :-().

    Maybe somebody at UT can help, sounds like a bug in the platform for specific hardware. Does the standalone version work ok (downloadable from right column)?
     
  5. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    The hardware is a dual quadcore 2,4Ghz pc with 4Gb ram and a PNY Quadro FX 5500 nvidia card.
    Should be good config. I don't have troubles with other unity content.
     
  6. tim

    tim

    Joined:
    Feb 3, 2007
    Posts:
    113
    The Unity plugin might be switching your monitor to a lower resolution whilst fullscreen.
     
  7. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    When I use other unity content in webplayers, then I get very high res when going fullscreen so no, thats not the problem.

    Its only with this demo that I get it.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    When doing web players, it's often a good idea to use ridiculously high values for the default screen size. That way full-screen will be in the user's desktop resolution, since it won't change to anything higher. The only reason not to do this is if you're doing heavy pixel shading, where potentially high resolutions would slow down too much.

    --Eric
     
  9. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    Ummm, I guess I must have missed something, default screen size? I don't see anything like that. I just use more or less the following code when going fullscreen:

    Code (csharp):
    1. Resolution res = Screen.currentResolution;
    2. int refresh = res.refreshRate;
    3. Screen.SetResolution(res.width, res.height, true, refresh);
    4.  
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yeah, in the player settings.

    --Eric
     
  11. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    Ah, I found the settings, never knew that you can go full screen with right button context menu. I'll change this in next build. In my demo you can go full screen with button in upper left corner, then the used resolution will be the same as current screen resolution.
     
  12. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    As several people seem to be interested in the source I made the source code available for download. You can get it from:

    http://ctrl-j.com.au/pages/jcarsrc.html

    Also updated the version in that when you use the buildin way to switch to full screen it should be hires. Anybody knows a way to disable this right-mouse menu of the plugin?
     
  13. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    now I see it ok in fullscreen.
    1 thing which doesn't look to nice is the shadow of the plants. I think you should push it up a lot higher OR just disable it.
     
  14. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    I use the standard shadows option (soft shadows) from unity, but must say it's not without artefacts, also quite disturbing is that having shadows on gives some kind of 'flickering' on some textured objects, like the car and the house. Any suggestions how to improve shadows are welcome!
     
  15. Dragon Rider

    Dragon Rider

    Joined:
    Jan 17, 2008
    Posts:
    280
    I like the style - feels like Mario 3D or something.

    But I hate the controls. It ranges from almost unresponsive to very sensitive and is extremely difficult to use, especially considering the narrow paths.

    How did you get real-time shadows on the terrain?
     
  16. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    The real time shadows is just the build in shadowing in Unity Pro. On terrain you have to make certain Lighting is set to 'Pixel' (and this somehow resets back to Lightmap every time you make a change to the terrain).

    The controls, yeah, I'm not really satisfied with the result but this is the best I managed to get using wheeled colliders. I'm considering using the wheeled colliders only for having wheels contacting floor and putting forces directly on car instead of the wheels, but I really would like to get it right with forces on the wheels. The source of the project is available, so feel free to update and improve the code:

    http://ctrl-j.com.au/pages/jcarsrc.html

    On the subject of wheeled colliders, maybe anyone has an idea, no matter how slippery I the tires make, when doing a sliding turn the wheels and car will loose all momentum and thus spectacular turns seem to be about impossible.
     
  17. Dragon Rider

    Dragon Rider

    Joined:
    Jan 17, 2008
    Posts:
    280
    IRL, they ARE impossible.. You only see them in movies because they were made for the movies. lol. It's a little difficult to get them to work in a game..
     
  18. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    Played with the wheel colliders a bit:
    http://protonfoundry.com/JCar/

    Settings
    Suspension Distance: 0.2
    Springs: 5000
    Damper: 10

    ShiftCenter.y = -0.28

    MaxSteerAngle = 30
    WheelDrive = All
    FwdStiffness = 0.15
    SwyStiffness = 0.03

    The only other thing I did was add 2 lines of code to make the rear more loose (well in JS it would have been 2 lines :p)
    Code (csharp):
    1. WheelFrictionCurve fc1 = wheels[2].col.sidewaysFriction;
    2.         fc1.stiffness *= 0.5f;
    3.         wheels[2].col.sidewaysFriction = fc1;
    4.         WheelFrictionCurve fc2 = wheels[3].col.sidewaysFriction;
    5.         fc2.stiffness *= 0.5f;
    6.         wheels[2].col.sidewaysFriction = fc2;
    Feels more like rally racing now. But I still have a heck of a time making it over the bridge consistently.

    EDIT: I found I preferred shorter suspension with a stiffer ride. It gives better control, but sacrifices the cool looking bounciness. Updated the player with:
    SuspensionDistance = 0.1
    Dampers = 100
     
  19. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    Thanks for your input!

    Somehow I end up with a car with way to little power, always when I mess with stiffness I have to adjust the torque. I'm taking (most) of your settings into my next build and will make the stiffness configurable for both front and back wheels. Hope to make a post today, although I actually should be working on my paid job, but hey, I need a learning platform, not?! Maybe I'll add some high-score (internet) and the ability to race against ghosts of other players. And maybe I should add a menu with sliders so everybody can tune their car (and have it stored with their high-score). So much possible, so little time...
     
  20. jkreijkamp

    jkreijkamp

    Joined:
    Dec 5, 2007
    Posts:
    129
    I totally redid the car scripts, now use animation curves (or how they're called) to map RPM to power, so you can easily and visually modify the characteristics of the engine. Also, it made the script a lot simpler. One thing bothering me still is how terrible the car steers at higher speed, suggestions to fix welcome.
    Besides the script, made gates on the track you have to pass and an indicator which direction you must go to next gate, some direction poles with simple damage and some other small stuff.
    Demo still has webplayer and mac/windows downloads, source also available for download.

    http://www.ctrl-j.com.au/pages/demo.html

    Please let me know what you think!