Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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 Vincentt123 · Jan 03, 2015 at 11:09 AM · scalespeedcar

How to get the accurate speed of a car with wheelcolliders?

I am making a simple car driving game and made a guiText for displaying the speed of the car. When I play the game in Unity Editor, everything seem to work well except for that the speed displayed doesn't seem very realistic (my car doesn't look like it's going that fast). The car drives on roads that have lane markings and stuff so I can tell that it is going too fast. Here is my code for calculating the speed. currentSpeed = Mathf.Round(2*22/7*wheelRL.radius*wheelRL.rpm*60/1000); I put realistic numbers for the wheel radius in the wheelcollider.

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

Answer by EvilTak · Jan 03, 2015 at 04:43 PM

Simply get the correct speed by using rigidbody.velocity.magnitude. It returns the speed in M/S. To get the speed in KM/H multiply the magnitude by 3.6f, and to get it in M/H multiply the magnitude by 2.237f. You don't need to do such calculations using wheelcolliders.

Comment
Add comment · Show 2 · 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 Vincentt123 · Jan 03, 2015 at 08:52 PM 0
Share

Thank you very much it worked

avatar image emilylena · Mar 31 at 12:35 PM 0
Share

This is not accurate, as this will give the speed of the rigidbody REGARDLESS of whether you are connected to the ground and REGARDLESS of whether you are moving forward or sideways.

To get an accurate reading you do in fact need to calculate it from a wheel's angular velocity.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Wheel rotation help cant work out the problem? 0 Answers

Car Steering Relative to Car Speed 2 Answers

Unity car tutorial speed boost 1 Answer

How do I limit the speed of my car? 0 Answers

Speed = 11 meters /s plane is 110 meters should take me 10 seconds but it dosn't 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