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 AVOlight · Jan 24, 2015 at 03:15 AM · mecanimintenum

Why can't I animate an int or enum?

Is there a way to animate ints or enums? (with mecanim)

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

Answer by SilentSin · Jan 24, 2015 at 03:54 AM

I don't think so. Only floats.

You'd have to animate a float and cast it to an int or enum everywhere you use it.

Comment
Add comment · Show 8 · 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 AVOlight · Jan 24, 2015 at 04:13 AM 0
Share

cheers, using a struct of bools. any idea why no int recording support?

avatar image Eno-Khaon AVOlight · Oct 23, 2015 at 07:36 PM 0
Share

If I were to guess, I would assume it's a purely logic-driven decision.

Let's say your game is running at 10 frames per second. You're scaling a value from 0 to 1,000 in one second. That means that every frame, the number grows by 100. But what if your game's running at 10,000 frames per second? Or even 1,005 frames per second. Integers are truncated, so any amount less than 1 per frame would round down to 0.

Additionally, Let's say you're running at 10 frames per second and are scaling from 0 to 970 ins$$anonymous$$d. That's 9.7 per frame, or 9 rounded down. You would logically only reach 900 after one second has elapsed.

Because of this, it makes much more sense to base it on a non-integer, with linear interpolation used to calculate the value at any time in the intended range.

So, yes, it really is the most reasonable approach to animate a float, without real framerate dependency, and then truncate the final value to use it as an integer.

avatar image Eluem Eno-Khaon · Oct 23, 2015 at 08:20 PM 0
Share

But you can go into the curves and set both tangents to constant which makes the float "snap" to the value at the key frame. This functions exactly as an integer would be expected to... I don't see why they can't implement integers and make them behave this way with out being able to be configured otherwise.

Similarly, booleans are already implemented... and they don't have some gradual transition.

The only difference between implementing a boolean and an integer, effectively, is allowing more than two states... and ins$$anonymous$$d allowing an arbitrary number of states.

Show more comments
avatar image SilentSin · Jan 24, 2015 at 04:15 AM 0
Share

They decided it was unnecessary? They couldn't find a good standardized way to implement it? Your guess is as good as $$anonymous$$e.

Please mark my answer as correct if your problem is solved.

avatar image Eluem · Oct 23, 2015 at 06:58 PM 1
Share

@biasless

They really should implement integers, but since they don't, it's fairly easy to just use a float and each time you add a key frame that references it, go to the curves screen, right click the frame, go to "Both Tangents" and click "Constant".

If they implemented integers, it'd basically function like that... except you wouldn't need to go into the curves screen each time.... or cast them lol

avatar image AVOlight Eluem · Oct 24, 2015 at 05:58 AM 0
Share

Thanks for the tip :)

i also wonder about why classes aren't allowed when they get serialized to $$anonymous$$onoBehaviour they lose there links to other unity objects anyway and become like a struct dedicated to the $$anonymous$$onoBehaviour that owns them. then you've got the benefit of reference in custom editors and GUIs and so on. right now i'm just using structs that also have a class version and syncing the changes between them as i animate. (reflections a bit heavy when you have multi layered structs that require setting each layer all the way to the top)

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

23 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

Related Questions

Get Enum member from int 1 Answer

Animation depending on the Int value 0 Answers

Integer value casting to KeyCode enum in JS? 3 Answers

Can't compare byte to byte? 2 Answers

No Avatar for Legacy rigs... Mecanim fails? 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