• 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 daymont87 · Dec 29, 2012 at 01:41 PM · carfliparcade

Unflip car

Hello! I'm using this script from documentation, to make a arcade car phisics.

 var speed : float = 10.0;
 var rotationSpeed : float = 100.0;
 
 function Update () {
     
     var translation : float = Input.GetAxis ("Vertical") * speed;
     var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
     
     translation *= Time.deltaTime;
     rotation *= Time.deltaTime;
     
     transform.Translate (0, 0, translation);
     transform.Rotate (0, rotation, 0);
 }

What i need:

  1. Get unfliping car, or make a fixed angle tilt of the car

  2. Off the controll car when it in the air, because it continues moving when i hold the button

  3. why it flies into the air when bumps into something on the speed? and twirl there like crazy too long?

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

1 Reply

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

Answer by deltamish · Dec 29, 2012 at 02:27 PM

Update HI,

1 . To unflip your car use this simple code(Its the same)

 var initialrot:Quaternion;
 
 function Start(){
  initialrot = transform.rotation;
 }
 
 function Update(){
 //your code to check if its flipped or not
 //if yes then
 if(transform.rotation.z >=180 && transform.rotation.z <360){///////to check if your car is flipped or not
 transform.rotation = initialrot;
 }
 }


2 . to check if you are grounded try using his script cause i am a little busy with my AI script so i am unable to post mine Here is his script (if you want a even simpler code so that you can understand please do notify me) Edit if you are using script from the link

 funcyion Update(){
 if(IsGrounded()){
 ///your movement code
 //from var translation to transform.Rotate (0, rotation, 0);
 }
 }

3 . And for the rotation when you bump.Actually the rigidbody will take care of it by its self

Comment
Add comment · Show 4 · 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 daymont87 · Dec 29, 2012 at 02:45 PM 0
Share

Thanks you for the fast answer! Actually i want phisics like here http://www.youtube.com/watch?v=aNmVIDE0SWg and i don't know which metod (CharacterController or Rigidbody) better for this( Which one better in you opinion?

avatar image deltamish · Dec 29, 2012 at 03:20 PM 0
Share

Hi,For that i think rigidbody would be way better option because you will get realistic collision physics

avatar image daymont87 · Dec 29, 2012 at 03:52 PM 0
Share

Ok, can you help me with the script please?)) I really try find out how did it, but i new in unity, and while it did not work(

avatar image daymont87 · Dec 30, 2012 at 12:38 PM 0
Share

Ok, thanks! I find out how to off car control in the air, tell me please, how can i define that my car is fliped? =) "//your code to check if its flipped or not"

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to check if an object has rotated around itself (360° in x,y,z) 1 Answer

Mario Kart Wii Physics 1 Answer

if occurs for continuesly for 3 seconds 1 Answer

Stop Wheel Colliders from flipping over 1 Answer

arcade car physics 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