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
3
Question by PeterB · Apr 01, 2012 at 11:12 AM · animationtime

Fast-forwarding an animation to its last frame

What's the best way to fast-forward an animation to its last frame?

The context is straightforward: in a multi-player game with an authoritative server, users logging on should see the last animation played for NPCs, but they shouldn't see the entire animation being played back. For instance, if a user logs on at a location where combat has just taken place, the user should see the relevant NPCs as dead and static – they shouldn't see the death animation played back. Thus, in that case, there is a need to fast-forward the animation to its end as part of the logic that sets up the state of existing NPCs. (No, buffering RPC calls is not a solution, the proxy NPCs must call the server for state info as part of their init sequence.)

This only applies to non-cyclic animations, of course: a "sleep" animation shouldn't be fast-forwarded in this way.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Bunny83 · Apr 01, 2012 at 12:46 PM

Usually most games have seperate idle animations for such states like dead. The dieing animation transits into the dead-idle. Anyway you can manipulate an animation as you like. Animations lika dead should have its wrapmode set to clampforever to be sure you reach the last frame.

You can set the AnimationState.time to any position in your animation at any time. You could als set the normalizedTime to 1.0 which will be the end of the animation. Note that a finished / stopped animation isn't sampled. Clampforever will still sample the last keyframe.

You can even sample any state at any time with Animation.Sample.

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 PeterB · Apr 01, 2012 at 12:57 PM 0
Share

Thank you, Bunny83, this is exactly the kind of information needed (I'm a backend programmer, not an animator). In this case I don't have access to separate dead-idle animations. The finished software will, though. $$anonymous$$eanwhile, I'll use normalizedTime to simulate them.

avatar image
0

Answer by Eristen · Oct 25, 2021 at 11:33 AM

In case you are doing this via an animator, then you can do this with the CrossFade (or CrossFadeInFixedTime) like so

 anim = GetComponent<Animator>();
 anim.CrossFade("SomeState", 0f, 0, 1f);
 
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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I read time from clip that is PlayQueued? 1 Answer

Animation.Time help 1 Answer

Timing multiple events at certain times? 1 Answer

Set the current time / frame of a Mecanim animation 5 Answers

How do I make a particle emitter emit when a key is pressed? 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