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
1
Question by Holynub · Nov 23, 2010 at 01:22 AM · physicsforcewheel-collider

Remove all forces on a wheel Collider

Hi all,

I have a simple vehicle that I wish to remove all forces from when I respawn it. I'm using 4 wheel colliders. Forward force is applied by using wheelCollider.motorTorque and braking force is done by brakeTorque. I can get the vehicle to respawn and set it's velocity to zero, but there's often some residual forces working on the wheels. From what I've read, the WheelCollider.rpm is a read only function. Is there any way to instantly set it's WheelCollider.rpm == 0?

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
2
Best Answer

Answer by Edy · Nov 30, 2010 at 10:12 AM

You can instantly force the rpm to zero by setting an infinite braking torque:

WheelCollider.brakeTorque = Mathf.Infinity;

However, those residual forces don't come from the rpm. For instance, when riding over a bump the first frame the wheel interpolates the bump there's no force applied. The next frame, as result of the calculations, the proper force is applied to the rigidbody. If a respawn occurs exactly in the middle, then the force will be applied right after respawning.

You should be able to disable the effects of those occasional forces by briefly making the rigidbody as kinematic after respawning. Something like this:

function FixedUpdate() { // (if the vehicle has been respanwed this frame, // then a variable respawned is set to true)

 if (respawned)
     {
     wheelCol.brakeTorke = Mathf.Infinity;   // Repeat for all wheelcolliders
     rigidbody.isKinematic = true;
     respawned = false;
     }
 else
     {
     rigidbody.isKinematic = false;

     // (do the torque calculations here as usual)
     }
 }

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 TTmylink · Apr 20, 2021 at 09:33 PM 0
Share

I know it's an old post but It caused me a bug on android. Mathf.Infinity give the WheelColliders NaN as rpm. Use float.MaxValue.

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

Hovercraft Physics Problems 1 Answer

Making a paper like object on Unity. 2 Answers

Returning a rigidbody back to its original x and z rotations through physics forces. 2 Answers

Make object stick to the ground in 2D 2 Answers

How to make a object jump constantly at y and move to the next position to z (perfectly) 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