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
17
Question by kacyesp · Sep 07, 2014 at 07:31 AM · booleananimation events

Why don't animation events allow you to call functions that take a bool parameter?

According to the docs, "The parameter can be a float, string, int, object reference or an AnimationEvent object."

Is there a good reason behind this? My only thought is that setting bool parameters during an animation is meant to be done somewhere else, but if that is the case, then where?

Right now I have a function which gets called at the start of each animation as an animation event:

 private void SetInterruptableFlag( int interruptFlag )
 {
     character.CurrentActionIsInterruptable = interruptFlag != 0;
 }

I know it's trivial, but I feel like I should just be able to directly set the variable equal to the value of the passed in argument instead of making an extra != comparison.

Comment
Add comment · Show 6
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 DESTRUKTORR · Oct 11, 2014 at 04:28 PM 1
Share

I would honestly chalk it up to deadlines. I can't come up with a reasonable explanation for why they would ignore bool arguments, apart from the idea that the animation event system is not yet fully fleshed out.

avatar image KarlKarl2000 · May 11, 2016 at 07:06 AM 0
Share

"+1" for me

Just today wanted to add a bool to my animation event.

Not allowed.

facepalm

avatar image bobmoff · Sep 13, 2016 at 10:42 PM 0
Share

ha ha, this is so silly that it doesnt work.

avatar image Bonfire-Boy · Sep 14, 2016 at 09:14 AM 3
Share

I take the point in the question, but it makes the current situation look worse than it is... a ternary operator isn't necessary there (just use interruptFlag!=0, it's already the bool that the ternary operator returns).

avatar image kacyesp Bonfire-Boy · Nov 15, 2016 at 03:14 PM 0
Share

You're super right lol I must have been tired. Can't believe I didn't realize that at the time. I edited the question to use the != comparison ins$$anonymous$$d of the ternary.

avatar image AllTheGoodNamesWereTaken · Feb 23, 2021 at 11:18 PM 0
Share

Erm, why is this still an issue 7 years later? Anybody know?

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by M-Elwy · Feb 23, 2021 at 11:39 PM

You can use Convert.ToBoolean(INT) method.

 character.CurrentActionIsInterruptable = Convert.ToBoolean(interruptFlag);

0 = False
Any non zero value = True (ex: 1, 100, -1, -100)

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 AllTheGoodNamesWereTaken · Feb 24, 2021 at 04:23 PM 0
Share

Thanks for the response. This is the work-around many people can use but it doesn't really answer the question of, Why do we have a float, string, int, & object parameter for animation events, but not bool?

avatar image Bonfire-Boy · Feb 24, 2021 at 06:55 PM 0
Share

And it's not really much of a workaround if you already have a function accepting a bool.


This question has re$$anonymous$$ded me of a similar curiosity. The PlayerPrefs class doesn't have GetBool and SetBool functions, so one gets used to using G/SetInt and doing the conversion. Not something I have a problem with in itself, but it seems odd then that the EditorPrefs class does have the Bool functions.

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

29 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

Related Questions

Animation Event Bool Function? 1 Answer

Better way to delay a function for a few seconds? Javascript 1 Answer

Can See Target not working 1 Answer

Changing Colour of an Object With a GUI.Button Back to Original 0 Answers

Array with boolean variables? 3 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