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 zacharif · Jul 11, 2019 at 04:59 PM · loop animaiton

How to make a animation stop looping.,How to destroy animation after played.

In my game I have dynamite and when it touches an object it is supposed to disappear and play the explosion animation once but when it touches the object the animation keeps on looping. Any tips to make it play only one time? I will reward anyone who tells me how to play the animation once with one reputation point =). Thanks!

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
1
Best Answer

Answer by I_Am_Err00r · Jul 12, 2019 at 04:02 PM

Let me help you out.

If I understand you want the animation to play when something enters the collider and then stop playing after one loop then destroy the object? I'm going to go with your example and see you call this in start; there are two ways to do this, I'll show you the Invoke() method.

For this to work, first setup a public float called time, or just define the time in the code where I wrote time:

 private void Start()
 {
 Invoke("Stop", time);
 }

then do something like this:

 private void Stop()
 {
 Stop = true;
 //I would have a reference to the animator component here to set that bool to stop, I don't see it in your script but mine would look like this: animator.SetBool("Stop" Stop);
 Destroy(this.gameObject);
 }

I'm not sure how you're animations are triggered, the example you showed just has it in Start, so I hope this is what you're trying to achieve.

Comment
Add comment · Show 5 · 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 zacharif · Jul 12, 2019 at 06:13 PM 0
Share

Shows me a bunch of errors but do you know how to delay time?

avatar image zacharif · Jul 12, 2019 at 06:19 PM 0
Share

Sorry I meant do you know how to delay time another way?

avatar image I_Am_Err00r zacharif · Jul 12, 2019 at 06:39 PM 0
Share

There are many other ways, but I won't share that with you because the Inovke() method is the easiest way and if you set it up the way I explained I'm 1000% confident it won't give you any errors.

Tell me what the errors are, or better yet can you just paste the actual script you are using and I will make it work.

avatar image zacharif · Jul 12, 2019 at 06:40 PM 0
Share

Found out why it did not work! $$anonymous$$y computer was glitching badly and did not respond to looping off. Now it works! Heres a point for helping me

avatar image I_Am_Err00r zacharif · Jul 12, 2019 at 08:42 PM 0
Share

I saw in my emails that you did accept this answer, but it seems to have reverted back; it would mean a lot if you would try again and make sure it highlights the answer as green. Thanks @zacharif!

avatar image
1

Answer by I_Am_Err00r · Jul 11, 2019 at 05:19 PM

On the actual animation file itself, by default unity always sets "Looping" to true.

Find the animation file you want, uncheck the looping box, done.

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 zacharif · Jul 12, 2019 at 03:08 PM

@skatesa207 Thanks for the help but I already tried that. It did not work =/.

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 zacharif · Jul 12, 2019 at 03:21 PM 0
Share

I almost got it! For all these people following please tweak it and comment if it works.

On collision or whatever triggers your animation. Write Destroy(this.gameObject); Send$$anonymous$$essage("Stop");

Your object will disappear and send a message, then on the animation write a script.

// Start is called before the first frame update void Start() { bool Stop = true;

     Destroy(this.gameObject);


 }

That means once the message is sent it will disappear, I just need to delay it to play the animation and then disappear. If anyone knows how to delay please comment.

Thanks!

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

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

Repeat loop every 5 secounds 1 Answer

Animations in the animator not looping 1 Answer

I can't put animations on loop. 1 Answer

button animation loop unity 2D 0 Answers

Animation looping although Loop Time is unchecked? 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