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
1
Question by Futurerobot · Jul 13, 2011 at 11:07 AM · animationmultipleadditive

How to play the same animation multiple times?

I've run into a problem I can't seem to resolve nicely.

I have a character which can react to "slaps" by playing back an additive get-hit animation. However he can be slapped quite frequently and I want each slap to get a slap reaction. But sending a crossfade call to the same animationstate just makes the current animation keep playing.

What I'm looking for is a way to make an animation blend to itself. In other words if "slap_left" animation is playing, and is called once again, the first playing version should blend out, while the same animation blends back in at time 0.0.

Setting time or rewinding it is too snappy, and the other solution I'm considering now is to have duplicates of the same clip and call them slap_left1 and slap_left2, but that seems a bit hackish.

Comment
Add comment
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

1 Reply

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

Answer by Waz · Jul 13, 2011 at 11:32 AM

I believe what you want is CrossFadeQueued with PlayNow mode:

   animation.CrossFadeQueued("slap_left", 0.2, QueueMode.PlayNow);

Yes, that sounds contradictory, I guess they should have called it "CrossFadeDuplicate".

Comment
Add comment · Show 3 · 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 Futurerobot · Jul 13, 2011 at 12:39 PM 0
Share

Beautiful, that's exactly what I needed. And yes, a bit misleading. I never thought to check out the Queuecommands when I wanted an animation to play immediately as a duplicate, ins$$anonymous$$d of playing after (as if queued) :)

There's only one problem that I noticed, when I use CrossFadeQueued, it refuses to play additively. With normal CrossFade it plays back additively, with CrossFadeQueued it plays back as a normal fullbodied animation. Is that a limitation on the queued playback, or simply a bug?

avatar image Waz · Jul 13, 2011 at 12:47 PM 1
Share

Note that, since it's a duplicate, you'll have to set the blend mode on it:

 var newstate = animation.CrossFadeQueued(...);
 newstate.blend$$anonymous$$ode = AnimationBlend$$anonymous$$ode.Additive;
avatar image Futurerobot · Jul 13, 2011 at 12:53 PM 0
Share

Thanks again! I didn't realize it was a duplicate animationstate until after I posted the question, noticed the little ": AnimationState" after the CrossFadeQueued command in the Scripting Reference. I ended up writing it like this:

animation.CrossFadeQueued("push_right",0.1f,Queue$$anonymous$$ode.PlayNow).blend$$anonymous$$ode = AnimationBlend$$anonymous$$ode.Additive;

Thanks a gazillion for the help, smooth way of playing impact animations achieved! This thing had me scratching my head for way too long.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Problem with additive animations 0 Answers

Using the same animation on duplicate objects. 2 Answers

multiple models same animation 1 Answer

How to combine mecanim and script based bone movement/animations? 2 Answers

Animation @ Naming System not working 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