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
1
Question by Muhwu · Dec 07, 2014 at 10:47 AM · animationmecanimparameters

Changing variable value from Mecanim?

Hello, I'm new to Unity and Mecanim and I'm curious about some things in Mecanim. Is it possible to change one of the parameters within Mecanim? Or what is the best way to achieve following:

  • I have two states: idle and zapping

  • I want to activate zapping, so I have a bool parameter "Zap"

  • I also have an animation the length of 0.5s after which it goes back to idle

  • Zap is still true! And the animation's stuck on loop.

What is the correct way to handle this - i.e. make sure that this is only fired once AND how do I attach some form of script trigger to the completion of the animation?

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 Muhwu · Dec 07, 2014 at 11:02 AM 0
Share

Ok so the Zap effect I can do using 'Triggers'. However, I'm still curious about setting values.

2 Replies

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

Answer by Muhwu · Dec 07, 2014 at 11:01 AM

Just found out about "Triggers". Figures.

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
avatar image
0

Answer by tanoshimi · Dec 07, 2014 at 11:03 AM

You set parameters in the Animator with SetFloat, SetBool, SetInteger etc., and you retrieve the current value of any parameters with GetFloat, GetBool, GetInteger, depending on the type of parameter: http://docs.unity3d.com/ScriptReference/Animator.html

In your case SetBool("Zap", true); will tell the Animator to transition to the Zapping state. If you want "Zap" to automatically uncheck itself after transition then you should use a "Trigger" parameter and call SetTrigger("Zap"); instead. However, I've personally found this to be somewhat unreliable, and prefer to manually unset my parameters in, say, LateUpdate() instead after I know the transition has occurred.

Comment
Add comment · Show 1 · 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 Muhwu · Dec 08, 2014 at 02:41 AM 0
Share

Hello there. I'm sorry, I didn't phrase quite correctly. I meant whether it's possible to actually set the variables (like "Zap" or the integers and variables) through the Animator window in Unity. The same place where you set the transitions without scripting. Like if I wanted an animator object to tell relevant data of it's states, previous states or such. I guess there's no way around this without scripting?

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

25 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

Related Questions

Random float parameter for idle animations 1 Answer

unity freezes when running sprinting animation 0 Answers

learn to scripting parameter in Mecanim 1 Answer

Animation will not Return to Proper State 2 Answers

how to set mecanim parameters for an ai? 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