• 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 wren945 · Mar 28, 2013 at 11:43 AM · mecanim

Mecanim: Can I force state transition immediately right after set parameter?

I want to something like this:

 anim.SetInteger(2); // could lead to state "attack"
 anim.EvaluateParametersAndTransitNow(); // how can I do this?
 // so that I can check current state in the same frame as the following.
 if(anim.GetCurrentAnimatorStateInfo(0).nameHash == Animator.StringToHash("Base Layer.attack");
 {
     // attack logic.
 }
Comment
Add comment · Show 5
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 Henry.T · Jan 17, 2014 at 08:09 AM 0
Share

A good question, why nobody answers? I'm in need of a solution too!

avatar image MrVerdoux · Jan 17, 2014 at 08:26 AM 0
Share

I´m not sure I understand the question, can you explain it further?

avatar image aeroson · Jan 17, 2014 at 12:54 PM 0
Share

Looks like answered here

Another solution could be to add an event into animation (call the attack logic function from within animation when it reaches certain point).

avatar image rhapsodyv · Jan 17, 2014 at 01:13 PM 0
Share

Did you try call yeild after anim.SetInteger(2)? so the code below will be executed in the next frame and the transition could already be made (if it's not atomic)

avatar image Antony-Blackett · Apr 11, 2014 at 01:01 AM 0
Share

I need this functionality as well. I have two cases for this.

1) I need to shoot a bullet, the bullet leaves from the barrel of the gun but the gun is positioned with a shoot animation. I want the animation to instantly snap to position so I can get the location of the barrel transform immediately. The next frame is not good enough in my case. This use to be possible with the animation.Sample() function but there doesn't seem to be an equivalent in mecanim.

2) I'm building a skinned mesh out of other skinned meshes. I need animation to be in the bind pose for this combining of skinned meshes to work. I need to instantly set the animation to the bindpose and then set it back to state it was prior all in the same frame.

Seems like a big missing feature in mecanim. :(

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

15 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

Related Questions

How to get current state on Mecanim? 4 Answers

Mecanim curve for move speed 0 Answers

Mecanim: BindSkeleton: Cannot find transform 2 Answers

How can I tell what AnimationState mecanim Animator is in from script? 1 Answer

Mecanim For Android! 1 Answer


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