Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ClanDestiny · Dec 18, 2015 at 04:22 AM · animationanimatoranimator controller

Animation Double Proc

Hello!

I've done some searching on this topic and found nothing that could lead to a solution (the most likely one being "it's buggy right now").

The situation is simply that I have a bool requirement for switching between animation states. The script (which uses OnButtonDown, I did research the issue) simply toggles the Animator's booleans and switches back to the idle state after an IEnumerator yield WaitForSecondses for the duration of the animation.

However the animation plays twice. The second time, the boolean on the left side of the Animator window is clearly unchecked, but it triggers a second time. I wouldn't even mind visually, but the lack of consistency between the boolean's value and what is happening could easily cause issues later on.

Any insight is appreciated!

P.S.: This might not be relevant, but as a side note I have managed to make it work "sort of". That is, with the animation (the one that is double played) having its speed set to 0.5, it plays only once. However I don't get why, nor do I really want that extra layer of finnicking to find where things will line up instead of using clearly marked timestamps.

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 ClanDestiny · Dec 18, 2015 at 04:23 AM 0
Share

I forgot to mention that I did try to lower the value of the yield WaitForSeconds to be shorter than the animation's duration, to no avail.

1 Reply

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

Answer by Zoelovezle · Dec 18, 2015 at 10:26 AM

alt textU should use trigger instead of this all stuff :)

Edit: Arrange your animations states in this way so it gets a entry state and exit state . Next deselect the "Has exit time" in Inspector while selecting the transition arrow ,like i have deselected it between Still state and Attack State . This prevents it from looping and cuts the animation in between.And one last important and best this is go find the animation clip and in Inspector make sure you have deselected the loop.(Only for animations which you dont want to get loop like my Attack State Animation clip have no loop while the Still Animation Clip have Loop .) alt text

 int TriggerHash = Animator.StringToHash("myTriggerNameFromAnimatorWindow") ;
 int animationHash = Animation.StringToHash("Base Layer.Run") ;
 
 Animator _animator ;
 private AnimatorStateInfo stateInfo ;
 
 void Awake()
 {
     _animator = GetComponent<Animator>();
 }
 
 void Update()
 {
     stateInfo = _animator.GetComponentAnimatorStateInfo(0) ;
     
     if (Input.GetKeyDown (KeyCode.X))
     {
         _animator.SetTrigger(TriggerHash) ;
     }
 }

U should Look more deep in learning - Every basic is provided in Unity Tutorials

Check here : Your Problem gets Solved in this tutorial http://unity3d.com/learn/tutorials/modules/beginner/animation/animator-scripting?playlist=17099


q.png (30.3 kB)
untitled.png (58.3 kB)
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 ClanDestiny · Dec 18, 2015 at 07:11 PM 0
Share

Tried this and it didn't work (that is it works, but it does the same as what I originally had). Removed all animators and implemented this from scratch, and it still triggers twice. I also encapsulated it in a void (ins$$anonymous$$d of IEnumerator) and the double play still persists.

avatar image Zoelovezle ClanDestiny · Dec 19, 2015 at 08:56 PM 0
Share

well wait i will update my answer @ClanDestiny and it will work .

avatar image ClanDestiny · Dec 20, 2015 at 07:19 PM 0
Share

The Exit transition doesn't seem to be necessary. However unchecking the Loop Time checkbox fixed it. I didn't think to look at the animation in the project resources, I was selecting it right from the animator screen assu$$anonymous$$g it was the same (therefore thinking I had looked at all options).

Thanks for taking the time to post this!

avatar image Zoelovezle ClanDestiny · Dec 21, 2015 at 10:00 AM 0
Share

Glad It helped :)

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

46 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 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

Animator Controller 2D RPG Best Practices 0 Answers

Animtion looping if joystick is held 0 Answers

Can I play an animation with only 1 image for a duration? 0 Answers

Velocity not changing value in Blend Tree 0 Answers

Animation stuck if i hold the trigger Button 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