Kart Racer (Mario Kart/CTR) Physics

Hello. I’m pretty new to Unity, and I’m still trying to get my head around how the physics engine works. I’m trying to create a cartoon-styled kart racing game, based on Mario Kart and/or Crash Team Racing. I’ve made a few attempts at this. My first one used the built-in WheelColliders, but I had serious issues getting the kart to stay upright (even when the centre of mass was as low as it could go, it was still possible for the kart to fall over). I tried a different tactic, which was to use Raycasts to align the kart to the ground, and apply the rest of the physics through the rigidbody. This didn’t work either, because the physics were horribly temperamental, and caused the kart to spin off in all directions as I tried to correct it.

My third attempt is what I have at the moment, manually coding gravity and movement so that it works nicely and smoothly, and always faces the right direction. This works very well (in fact, better than the last, as I have control over the direction of gravity, which will be helpful later in the project). There is an issue with this, though. The kart can’t collide with walls, and will sometimes go through the floor, because there is no collision detection. I can fix both these problems by adding a rigidbody, and fixing it’s position and rotation, but then it causes an awful jittering, which makes the game virtually unplayable.

Essentially, my question is this: How could I build a racer without the realistic physics emulation built into Unity? The features I’m trying to include are:

  • Kart always faces the ground
  • When Kart leaves the ground, it orients vertically
  • Kart can collide with walls if they are too steep
  • Kart can accelerate and decelerate
  • Kart can turn with a fixed degree of rotation
  • Kart can skid when a button is pressed
  • Kart can jump a small amount when a button is pressed

I can get most of these working, but there are always one or two that just never seem to come out right. I’m sure it’s not an overly complicated engine to build, but since I’m so unfamiliar with Unity, the method for doing so always seems to escape me. I’m used to having to build everything from scratch, so this script method of programming is very jarring for me, and it makes things that should be simple just that little bit more complex.

Anyway, some help here would be most welcome. I can post what code I have if it would help.

I got pretty much everything working. I used this code as a base, and built it from there: non-gravity racing game prototype [Unity3D] - YouTube


I I’m currently working on a similar project and I would love to take a look at your project or see how you did it more in detail.

Currently I’m using an etererly physics based aproch but it have its disatvantages so I would love to get to see some more sample codes from other arpoches.