• 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
0
Question by Silver_Frog · Jul 16, 2016 at 06:51 AM · physicscar

How to unflip a car?

For my car I have a ridged body, box collider, four wheel colliders and a movement script. It works pretty well for the most part but when I drive off a ramp or bumpy terrain it will roll over and sometimes land on its side or back. I want it to automatically correct its position when it does that, how can I do 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 Fox_GAMING · Dec 08, 2020 at 01:33 AM 0
Share

Hi, were you ever able to figure out a solution for this?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Llama_w_2Ls · Dec 08, 2020 at 04:03 PM

Even though the OG has probably moved on, I'll try my best to answer the solution with a set of methods:


1. Rotate the car

Normally, the car should be upright when the x and y axis rotation is equal to 0. The z-rotation should remain the same, as to keep the direction the car was initially facing.

You can do this by setting the transform.rotation of the car. E.g:

 void Unflip()
 {
     Car.transform.rotation = new Vector3(0, 0, Car.transform.rotation.z);
 }

You can have a smoothing value so that it doesn't just teleport to an unflipped position, but slowly rotates itself, maintaining the physics.


2. Adding Force

By adding a force to stabilise the car, you can unflip it in a much smoother and controlled manner, than by manually setting the rotation.


To calculate the direction and magnitude to apply the force, you might need to do some testing. Adding a force upwards to the Car with a slight incline, will cause it to tip. The magnitude will be dependant on how large the flip was. If it's totally upside down (on its back), the magnitude will be great. If it's just on its side, a little nudge in the right direction should do the trick. Preferably applied to the top of the car.

Comment
Add comment · 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

my car keeps fliping over i have an idea how to fix it but i need help 3 Answers

Square wheels 4 Answers

Car tutorial physics models rotating randomly? 1 Answer

Applying proper drag and center of mass for a vehicle 1 Answer

Car goes a bit left when moving 1 Answer


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