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
5
Question by unsingefou · Jan 17, 2014 at 03:42 PM · animatormecanimtwice

Mecanim when call setTrigger, plays next clip twice

I am working on a simple 2D matching game. The facedown state is a simple animation that is 1 second long and loops. The idle state is for the card when it is face up. A 2 second animation loop plays here for the character on the card. The flip state is an animation that rotates the card, simulating a flip.

I have a simple state machine:

![alt text][1] [1]: /storage/temp/20763-statemachine.png

Transitions:

  • faceDown -> Flip transition when the flipTrigger(Trigger) event is called

  • Flip -> Idle transition on Exit and if isFaceDown(boolean) = false

  • Idle -> Flip transitions when the flipTrigger event is called

  • flip -> faceDown transition on Exit and if isFaceDown = true

The problem though is that from both the faceDown and Idle states, when I call the flipTrigger, the flip state actually plays through the animation twice.

Loop Time for the flip animation clip is toggled off.

I'm really at a loss here. Any help would be much appreciated!

Thanks!

statemachine.png (27.2 kB)
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 Fattie · Nov 08, 2018 at 11:26 AM 0
Share

THE TRANSITION LENGTH $$anonymous$$UST BE SET TO ZERO - an annoying gotchya.

2 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by kento14 · Jan 02, 2017 at 10:15 AM

@LeandroExHuMeD hopes this helps :)

Here is the run animation running 2 times. 1 time of its full length, and one time with the starting bit, where it transitions over to the death animation. alt text

Here is the exit Time set to a little under 1 and transition duration set to 0 that means that the run animation only will run 1 time of its full length and then go to the next animation. alt text :)


wrong.png (203.4 kB)
right.png (199.9 kB)
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 YasinDev · Nov 19, 2018 at 05:14 AM 0
Share

This worked for me just. if you want to smooth transaction between animations set exit time to 0.75.

avatar image
4

Answer by Vyross · Jan 26, 2014 at 02:03 PM

Just spent literally two hours trying to find out the answer to this. Here's what was going on with me:

I had two states: Fire and Idle. Under the transition between Idle -> Fire, there was a gradient. I had to scroll to the right (hold middle mouse button and drag). Fiddle with that, and you can adjust the timing, how many times each animation plays during the transition, and so on.

Comment
Add comment · Show 9 · 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 unsingefou · Jan 27, 2014 at 03:54 PM 0
Share

I spent about the same time messing around with the transition myself. However, I was not able to fix the multiple triggers. In the window that you are referring to, I made sure that each clip only appears exactly once. Still very strange!

avatar image ckrin · Aug 14, 2014 at 03:25 AM 2
Share

same thing here, but i solved it. if your clip is very very short your condition is set to exit time, your exit time has also to be very very short. Else the clip gets triggert twice wich seems to be intended :)

good luck!

avatar image Seneral · Nov 15, 2015 at 08:18 PM 3
Share

Had this problem, too. but my solution was rather simple and I found it out quickly. Anyway, in some cases this might be the problem, so I'm adding it here. I set the trigger in a if clause, condition Input.GetButton ("Jump"). This resulted in setting the trigger as long as the button is pressed, usually atleast a few frames. Due to the way trigger work, triggers only set themselves off when they are used (transitioning to jump). That means, if the trigger gets called atleast two and up to animationFrameCount-1 times in a row, your animation will play twice. The solution in my case was checking for Input.GetButton*Down* ins$$anonymous$$d:)

avatar image acharyashri Seneral · Aug 05, 2018 at 06:43 PM 0
Share

Thanks, this worked for me.

avatar image CoolCosmos Seneral · May 26, 2020 at 05:03 PM 0
Share

Thanks mate :)

avatar image kento14 · Nov 19, 2016 at 03:04 PM 0
Share

It worked for me :)

click on the transition, in the middle of the inspector, you should see a graph thing.

make sure the arrow and the eye are at the same place.

this will fix that very short animations run multiple times when you use triggers.

hope it helps.

avatar image LeandroExHuMeD kento14 · Jan 02, 2017 at 02:45 AM 0
Share

what do you mean by "arrow" and "eye" ? I need to fix this problem.

avatar image kento14 LeandroExHuMeD · Jan 02, 2017 at 09:50 AM 2
Share

@LeandroExHu$$anonymous$$eD hopes this helps

Here is the run animation running 2 times. 1 time of its full length, and one time with the starting bit, where it transitions over to the death animation. alt text

Right method: Here is the exit Time set to a little under 1 and transition duration set to 0 that means that the run animation only will run 1 time of its full length and then go to the next animation. alt text

wrong.png (203.4 kB)
right.png (199.9 kB)
Show more comments

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

24 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

Related Questions

How to use mecanim to play specific animation clips when public static int condition is reached? 2 Answers

Referencing an Animator component from a parent object? 1 Answer

Make mecanim transition after a delay in Unity3D 0 Answers

Imported model partially disappears 2 Answers

Mecanim. Why cant I get current state name? 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