• 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 Metaljack · Nov 24, 2012 at 06:45 AM · animation

Repeat Animation set amount of times

Hi,

I'm trying to loop an animation x amount of times.

For example: //Play animation 5 times animation.Play("animation", 5);

Not sure how to go about doing so, as WrapMode seems to either play once else loop forever.

Thanks in advance.

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

3 Replies

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

Answer by IT_Criminal · Nov 24, 2012 at 08:37 AM

 for(int count = 1; count <= 5; count++)
 {
     animation.PlayQueued("animation");
 }

this should do it :)

in "count <= 5" replace 5 with the amount that you need

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 Metaljack · Nov 25, 2012 at 07:56 AM 0
Share

Thanks that worked a treat. Feel like an idiot now for not realizing that. ha!

avatar image IT_Criminal · Nov 25, 2012 at 08:21 AM 0
Share

anytime :)

avatar image uzairamirs · May 19, 2016 at 07:34 AM 0
Share

Great answer. To the point, precise and accurate.

Thanks IT_Criminal

avatar image savelievpetr · Jul 30, 2019 at 04:15 PM 0
Share

AnimationStateInfo.normalizedTime shows per cent of animation time. It can be greater than 1 when animation is looping

avatar image
0

Answer by smock_74 · Jan 15, 2020 at 09:05 AM

for me it doesn't work for loop, it just repeating itself infinite and it's even too quickly does the loop

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
avatar image
0

Answer by Klarax · Jan 15, 2020 at 11:44 AM

can you modify the animation to call a function at the end of the animation - which would basically be a counter, and the stop it etc if it gets to the number you want?

naturally this only works in the animation is editable and not read only etc.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 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

Related Questions

Can I make animations snap to a frame? 2 Answers

How to select an animation clip by index number? 7 Answers

Can the animation editor create local rotational data? 3 Answers

Adding animation clips via script 2 Answers

2D Animation position translation 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges