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
0
Question by TheCount · Jan 18, 2014 at 02:31 AM · rotationrandomcarracingtorque

Random Turning?

I am making a racing game.

I did the physics weird, but I'm not sure that's the problem.

The physics work like this : The Car is a rectangular box collider. The velocity is changed to 50 every update. Steering is done by adding a torque on the axis. No wheels are involved. Basically it is just a block sliding and turning. It drives on friction free items only. The velocity is instantly changed to forward by:

 rigidbody.velocity = rigidbody.velocity.magnitude * transform.forward;

 

every frame. This works perfectly on terrain but when it is driving on cubes instead of a terrain, it sometimes, rarely, but it happens, randomly turns really hard like 90 degrees or it will sometimes randomly jump in the air.

I have tried changing it to adding a force instead of changing the velocity and that really makes no difference. It still turns randomly.

Any ideas on how to fix this?

Or at least what causes it?

I figured something else out: it happens when switching colliders that it is sliding on. For example, it slides over cube one and then jumps randomly when it transfers to cube two.

Comment
Add comment · Show 5
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 getyour411 · Jan 18, 2014 at 02:37 AM 0
Share

Is this happening in Update or FixedUpdate

avatar image Invertex · Jan 18, 2014 at 02:38 AM 1
Share

If you're talking about cubes as basically a bunch of cube/square colliders aligned together, that's a core issue with Unity that's existed for a while now, and is a huge issue with the 2D toolset as well. It will sometimes detect the edge of the cube, even though it's flush with the ground, and collide with it, resulting in you either spinning away, being launched upward, or co$$anonymous$$g to a dead stop.

avatar image TheCount · Jan 18, 2014 at 02:49 AM 0
Share

It is in FixedUpdate. Is there any way I can get around this glitch? And yes I'm talking about cubes aligned together.

avatar image Invertex · Jan 18, 2014 at 02:57 AM 0
Share

The way the Unity $$anonymous$$m suggests is to use a Sphere collider ins$$anonymous$$d... As if this is fine for any situation, but it's not for many people =/ It might be for your game though? You could still have your box collider for colliding with everything else, but have it raised slightly from your sphere collider (perhaps put a sphere collider in each wheel well even as pretend wheels)

avatar image TheCount · Jan 18, 2014 at 03:36 AM 0
Share

It still happens regardless of type of collider

1 Reply

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

Answer by TheCount · Jan 18, 2014 at 10:19 PM

I solved the problem, for anyone else experiencing this problem.

  1. Turn off gravity

  2. set a raycast to the ground of a small distance

  3. If the raycast doesn't hit, then make a downward force to simulate gravity

  4. if you are over the ground, transform the y(vertical) position of your object to a small amount higher than the object it hits.

This way, you are floating just above the ground. It works for me.

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.

Follow this Question

Answers Answers and Comments

19 People are following this question.

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

Related Questions

Help with ramdom and rotation on a car 0 Answers

inertiaTensor stopping automatic rotation 1 Answer

How to check if an object is upside-down? 2 Answers

Car tutorial physics models rotating randomly? 1 Answer

car suspension and torque help 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