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 Smike · Apr 06, 2013 at 11:34 PM · animatortransitioncondition

Any difference between using 0.1 and 0 for my conditions in my animator transitions?

I noticed that in most Unity tutorials, they use transitions with conditions such as "Less than 0.1" or "More than 0.1". Why is that? Wouldn't 0 be preferable? Or is it to make the transitions seem less stiff/robotic?

Sorry if it's a stupid question.

Comment
Add comment · Show 1
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 Fattie · Apr 07, 2013 at 08:06 AM 0
Share

dude HOW $$anonymous$$ANY FRA$$anonymous$$ES in your animation ?

say it has 4 frames.

so frame [2] for instance is um 0.500 until 0.7500

note that if you try ANY NU$$anonymous$$BER BETWEEN THERE, you're still really just getting frame 2

(with some smoothing, but that's another issue)

it could be this is what's tripping you up

1 Reply

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

Answer by Lockstep · Apr 07, 2013 at 12:46 AM

Well in real life maths any number can be memorized exactly. But the computer can't do this. It only has finit memory to save a number. The computer has two basic types of numbers it can save: integers and floats.

Integers are numbers {..., -1, 0, 1, 2, ...}. Integers are exact thus you can compare them with an equal sign ( == ). But due to the limited memory there is a maximum which the integer can't exeed. This means a 16 bit integer can actually be out of this set: {-32.768, ..., +32.767}

Floats on the other hand are numbers like 1.234567E+20. The computer saves the first couple of numbers (7 for the 32 bit float) and an exponent. The biggest (ignoring the sign) float possible is 1.79E+308 and the smallest is 1E-44. A far bigger range than the integer. The downside is, that floats are not exact. You usually have a hard time comparing two floats with the == operator. Instead check if the difference between two floats is close to zero.

Enough with the general talk. Back to your question. If you want to, lets say, animate a person. You have a running animation and an idle animation. Of course you want the running animation to play if the character runs and the idle animation otherwise. If you would check velocity.magnitude == 0 as condition, then the running animation would be played even if velocity.magnitude would be 2.463E-7. The character would run happily on the spot. Not good.

Short answer: Getting a float to an exact value is not always possible. You should never use == to compare a float since floats are not exact and this could lead to unwanted effects (see the example above). To compare to floats, sustract them and see if the result is small / close to zero.

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 Smike · Apr 07, 2013 at 02:12 AM 0
Share

Thank you for the straight forward answer!

avatar image whydoidoit · Apr 07, 2013 at 08:02 AM 0
Share

Should just point out that Unity's $$anonymous$$athf library contains a function called Approximately that can be used for comparing floats with specific values.

avatar image Smike · Apr 07, 2013 at 08:03 AM 0
Share

That's nice to know, thanks!

avatar image chelnok · Apr 07, 2013 at 02:42 PM 0
Share

Very good answer! @whydoidoit do you know what is behind Approximately function? What are the rules for getting true (return value)? Documentation only says "if they are similar".

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

14 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

Related Questions

Animator bug when activating a transition condition using SetBool 0 Answers

Animator dont transition to self or any sub state 2 Answers

Parameterize the Animators transition condition (in 2D) 1 Answer

Complex condition of animator transition via script 2 Answers

Animator problem with multiple sprites and one controller 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