Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Mario Kart Physics

Discussion in 'General Discussion' started by DaVeF101, Apr 21, 2016.

  1. DaVeF101

    DaVeF101

    Joined:
    Sep 7, 2014
    Posts:
    134
    I'm currently sketching out a Mario Kart style game in Unity.

    After observing Mario Kart 8 and playing it, I'm still unsure about how they implement the physics of the Kart in the game. Is the kart actually being 'driven' around the track using torque force at the wheels? Is Kart just animated on the spot (being effected by collisions) and the camera moves (with the Kart) ? (This would explain how it can be driven upside-down on some tracks). Or do they use shaders to twist the track about?

    Any thoughts on this would be great.. thanks in advance.
     
  2. L-Tyrosine

    L-Tyrosine

    Joined:
    Apr 27, 2011
    Posts:
    305
    I believe that this can be achieve with standard unity physics with some tweaks (by script).
    I would not work with wheels physics. Just a standard box collider (each car) with rotations locked on Y vector only.
    Some drag, friction and limiting on velocity and angular velocity.
     
  3. DaVeF101

    DaVeF101

    Joined:
    Sep 7, 2014
    Posts:
    134
    After giving this some thought, I think i'll have a play around with raycasting down from the Kart at each corner and making sure a constant distance is maintained (sticking the Kart to the track), this will allow for loops and weird twisty tracks. The actual movement will be Translate or Velocity from player input on the game object.

    But still not sure this is the correct or best method.
     
    Last edited: Apr 21, 2016
  4. L-Tyrosine

    L-Tyrosine

    Joined:
    Apr 27, 2011
    Posts:
    305
    To allow loops, you can disable global gravity and project gravity locally on each car by track normal.
     
    jbussing and shuwatch like this.
  5. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,541
    Mario Kart has nothing to do with physics.

    It's an arcade racer, not a simulator.

    You should prototype different types of character controllers and find what works.

    Personally I see a raycast shooting straight down to see the angle of the track and the material it's on.

    Then use triggers, not colliders, to see what it's touching and react accordingly.

    Also, tweak the camera to narrow its angle and pan out to increase a sense of speed.
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    @Not_Sure I couldn't disagree more. Whenever you add a number to another number, that's used in movement, this is physics. All games which have arcade gameplay use physics, and likewise things like GTA will use a physics engine for driving, even though it's not remotely realistic... physics do not need to be realistic. They do however save a lot of time. You can for example set velocity manually so you get all the benefits of a physics engine without being constrained in "simulation space".

    Most games will use a physics engine and I'm pretty sure mariokart does too. In the case of Mariokart snes, this has been reverse engineered and features a simplistic physics model which adds force in the direction of screen "forward" (it's all actually 2D). The newer mariokarts do need a physics engine.
     
  7. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,541
    Really?
    I stand corrected.

    Thank you.
     
    Superlegend06 and frosted like this.
  8. AdventurousDrake

    AdventurousDrake

    Joined:
    Mar 18, 2015
    Posts:
    25
    I don't think Mario Kart 8 uses a physics engine at all, it's just programmed the "old school" way to achieve what we perceive as physics. But If one pays close attention while driving though, you'll probably notice that it's not the car that is moving or reacting to the track, but it's the track that is reacting and adjusting itself to the kart. Well, I could be wrong of course, but I feel there is a reason why it's so difficult for developers to replicate what Nintendo is doing.
     
  9. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    IMO they probably have a custom physics solution. I doubt the cars have wheel colliders or anything like that on them it's probably more hand done then that with center of mass and torques and stuff.

    Umm no? Of course you can't see it. I don't actually think they use that method at least at the gameplay level... Moving the world just sounds like it's asking for trouble.

    The Mario Kart series is actually quite interesting as they keep the same feeling(At least to me, not an avid player) across nearly all the games from GameCube to DS to Wii-U I wonder how many magic numbers they have and how much code is actually the same on Mario Kart DS and Mario Kart 8.

    These guys did a cool video on creating cart physics that feel good:

     
  10. DaVeF101

    DaVeF101

    Joined:
    Sep 7, 2014
    Posts:
    134
    That's a very interesting video, thanks.
     
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yep, for my arcade tanks stuff, I still use suspension springs (these are raycasts with a spring physics model) and rigidbodies with forces.
     
  12. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,967
    Ummm... you realize this the internet right? The proper response would have been to post a wall of text arguing every point and calling his character into question.

    Noob.
     
  13. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    If it works and provides desired result, it is.
     
    zombiegorilla likes this.
  14. BIG-BUG

    BIG-BUG

    Joined:
    Mar 29, 2009
    Posts:
    457
    Maybe a constant down-force (to car normals) could do the trick? You probably want to apply it only when the car is grounded to allow for jumps...
     
  15. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,605
  16. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Cool thing, though a little bit pricey. I bet I could make such thing in 5h max. Too bad I don't make kart game right now.

    Also a good thing that creator of this asset made it with very bad graphics that only tangentially resembles what they are supposed to resemble. At least no one in the right mind will asset flip it and put as-is on the Greenlight, unlike UnitZ or Hammer (that shooter thing) assets that have good graphics (or at least not terrible) and had I not know these are "starter kits" I'd thought that those are actual games.

    That's why if I decide to make a kit (let's say 3d platformer kit since this is type of game I'm making right now) I won't include any graphics at all and it would be just basic primitives so nobody in the right mind would try to pass it off as their "game" as even if voters wouldn't notice the flip (which they probably would), they'd laugh "developer" off the stage for graphics. Plus with only Unity primitives and no textures/sound, asset would be just smaller to download.
     
  17. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    And be payed $8 an hour? Cheaper just to buy it. Then again this asset isn't really of the quality a game like Mario Kart is so it's not actually a solution.

    IMO an asset demo should be a snapshot of what is possible with the asset. If you made an asset that was just primitives I'd just skip over it as it's not showing me a 3D platformer, I couldn't gauge if this asset is actually up to the task of being used to create a 3D platformer.

    If you look at the top assets like Curvy, Final IK and SVG Importer they all have demos that are game ready, like a little snapshot of what an awesome thing made in this asset would look like.
     
    Ryiah likes this.
  18. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    That's why I'd have a WebGL 1 level demo to check the gameplay of the asset, but graphics-wise it would be just primitives to avoid UnitZ situation (someone still might try that but even if people wouldn't notice the flip they'd laugh at developer for the "graphics" and no sound).
     
    Unity-Artcraft likes this.