Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by akamaru · Jun 21, 2016 at 04:00 PM · scripting problemnumbers

How to handle a infinite 2.3333333 number?

Hello everyone

I'm on a project to make a kind of simulations of planetary gears alt text

as I can not make them react to each other with the colliders

I try to do it with a Script that calculates the speed of each part as a function of the input speed and the role that each party shall perform

in this case, the sun is the entrance, the carrier is stationary, and the ring is the output

the calculation for ring ratio would look like

-S/R = -52/92 = -0,5652173913043478

and for planets ratio would look like

-S/P = -52/20 = -2,628260869565217

Now, I have the speed of the input into an int, so to be, for example 45 the velocyty for each part would look like

VR= 45*-0,5652173913043478 = -25,43478260869565

Vp= 45*-2,628260869565217 = -118,2717391304348

but for some reason Unity does not use numbers with decimals all full, and thus, do not get the proper spin on each gear

this had me upset the script works so fine but, the end is not that all,

any idea how to fix this?

instead of doing it this way

Will there be another?

for example, it occurs to me that not as a function of its speed but in terms of its angle of rotation, but not really seriously need to fix this.

I appreciate all the help you can give me

sin-titulo.png (236.9 kB)
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

Answer by Dibbie · Jun 21, 2016 at 05:50 PM

Im assuming your using a comma (,) instead of a period (.) as its easier to see in your calculation? But in Unity, you should certainly be using a period/decimal (.) whatever youd like to call it.

Float conversions have to be continuous, so even for example, your 45, should be 45f or (float)45 so that math takes every number as a "float" when converting.

If it isnt calculating all numbers, try using a long, or a double, another thing you could try is BEDMAS to handle larger numbers into a temp variable, then calculate the result of both of those into a even longer variable. Your numbers dont seem like they would be too large for a float to handle though. I cant remember how many digits a float is capable of managing off the top of my head, but im confident its more than what you have there.

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

67 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

Related Questions

Add "1" to score text? Not "11111"? 1 Answer

How to make a number higher than Quintillion? (1000000000000000000) 1 Answer

Why do I keep getting this error? 1 Answer

Player Lap System (Racing Game) 0 Answers

My Instantiated enemies do not add there score to the score counter. why? 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