Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 harish_unity986 · Jul 14, 2021 at 11:10 AM · physicsrigidbodywheelcollidersimulationwheel

Calculate Distance using WheelColliders

I created a 4WD , i want to calculate the distance travelled by the car using only wheel colliders , based on the motor torque applied to the wheels.

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

3 Replies

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

Answer by Edy · Jul 14, 2021 at 06:29 PM

You may convert the angular velocity of the wheel into linear velocity using the radius and accumulate it:

 float distance = 0.0f;
 
 void FixedUpdate ()
 {
     float angularVelocity = myWheelCollider.rpm * (2.0f * Mathf.PI) / 60.0f;
     distance += angularVelocity * myWheelCollider.radius * Time.deltaTime;
 }

Note that this solution doesn't have the wheel slip into account. If the wheel is slipping in place, then the distance will still be increased as per the distance traveled by the surface of the wheel.

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 harish_unity986 · Jul 16, 2021 at 06:44 AM 0
Share

thanks for the solution , i tried it and it works for smaller distance and as distance increases the error increases , how do i counter wheel slip to calculate distance accurately.

avatar image
0

Answer by gabgab06 · Jul 14, 2021 at 03:51 PM

I'm not sure but :

 float _distanceTraveled;
 Vector3 _lastPosition;
 void Start() 
 {
         _lastPosition = transform.position;
 }
 void Update() 
 {
         _distanceTraveled += Vector3.Distance(transform.position, _lastPosition);
         _lastPosition = transform.position;
 }


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 harish_unity986 · Jul 14, 2021 at 04:04 PM 0
Share

@gabgab06 thanks for reply. But im looking to find it using circumference and using that the distance travelled.

avatar image b1gry4n harish_unity986 · Jul 14, 2021 at 05:53 PM 0
Share

is there a reason youre trying to do it based off the circumference? gabgab06 answer will give you the total distance traveled, it just wont be calculated based off the circumference. in order to calculate the distance traveled using circumference you need to know when a revolution of the wheel happens.

think of it like taking a tire, cutting it and laying it flat (inco$$anonymous$$g sick ascii art)

O -> ___

The circumference of the tire is equal to the distance traveled for each revolution of the wheel. so for example if your tire has a circumference of 2m in 20 revolutions youve gone a 40m distance

circumference = 2* pi * radius

avatar image harish_unity986 b1gry4n · Jul 14, 2021 at 05:57 PM 0
Share

i want it in that specific way, i got an idea to manually calculate the circumference of the wheel and based on that input calculate the distance travelled by the wheel . I will post the solution if anything comesup . Meanwhile, thank you @b1gry4n

Show more comments
avatar image
0

Answer by harish_unity986 · Jul 17, 2021 at 04:09 AM

Solution above

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 rage_co · Jul 17, 2021 at 05:35 AM 0
Share

nice....simple but effective...good job

avatar image Edy · Jul 17, 2021 at 10:11 AM 0
Share

It's exactly the same as $$anonymous$$e xD (it only returns abs distance instead of signed distance)

avatar image rage_co Edy · Jul 17, 2021 at 12:11 PM 0
Share

yep cool....

avatar image harish_unity986 Edy · Jul 20, 2021 at 11:28 AM 0
Share

yo @Edy my bad man , i used your solution but was experimenting with wheels , so got wrong results , your answer is very accurate , thanks a lot.

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

234 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Wheelcolliders stuck in ground 0 Answers

Square wheels 4 Answers

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

Issue using wheelColliders around sphere 1 Answer

My motorcycle's rear wheel doesn't slide like it does in real life when applying brakes 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