Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Cam · Jun 01, 2010 at 05:54 PM · physicscarsimplesteeringmario

Mario Kart-style car Physics

I would like to make a racing game, like Mario Kart, so with very simple physics. Using car tutorials that are already out there, seem too complicated as I don't want all the features - no gears, rolling over if you're going too fast round a corner etc.

Ideally, all I want is a car that I can keep really simple. So having an object that accelerates up to a top speed, has a set turning angle and won't turn when its not moving and has simple rigidbody physics such as bouncing and skidding off walls and other carts. This is I think how the MarioKart carts work - when they get hit by a weapon they just have a simple animation - no physics.

What's the best way to implement this?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PixelProtist · May 23, 2014 at 06:23 PM 0
Share

What about if you wanted to have an undulating track? Then you'd have to have a system where the cart tilted to align with the ground beneath it.

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Cap · Jun 02, 2010 at 07:08 AM

I'll just post some code snippets that I'm using in my own project here along with some pointers for the rest. These don't take into account drag so you'll need to add some of that to your karts via their rigidbody, otherwise they'll never slow down once the player lets go of the forward key.

Acceleration and limiting top speed:

// for acceleration var throttleforce = accel; // this is the acceleration speed of your kart if(Input.GetAxis("Vertical")>0) { // forward key down rigidbody.AddForce(transform.forward * Time.deltaTime * throttleforce); }

// for limiting kart max speed
var v = rigidbody.velocity; // current speed
if(v.sqrMagnitude >= truemaxspeed){ // truemaxspeed is the max speed max speed. // calculate that in the awake or start events so you don't bog things down. rigidbody.velocity = v.normalized maxspeed; }

You should be able to use the steering from existing car tutorials and just cut out the bits you don't need, so I won't bother posting that code here. Remember you can use Time.deltaTime as a multiplier for your kart spec values to make them time based, thus letting you set a particular degrees per second rotation for your limited turning circle.

The physics can be handled quite easily with rigidbodies and you can lock down rotation along x and z and movement along y (if you don't need jumps on the course) using a configurable joint or by just forcing those values to 0 in code.

Setting up what happens when a kart is hit by a weapon can be handled by checking the IsTrigger box on the weapon's collider and then using the subsequent event to spin the kart or whatever you want to have happen.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PixelProtist · May 23, 2014 at 06:28 PM 0
Share

What exactly do you mean by a 'configurable joint?' Does that mean you could align the car with the ground beneath it, as that would be useful for sloping tracks.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Mario Kart Style Car Physics II 1 Answer

Connecting steering wheel to front wheels 0 Answers

Setting Wheelcollider BrakeTorque to 0 does not release brake 0 Answers

Steering an AI vehicle to a waypoint using float of -1 to 1? 1 Answer

How to tumble player car on collision with enemy car? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges