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
0
Question by Macarse · May 03, 2012 at 06:35 PM · particlespoolrecycle

Recycling particle system

I am implementing an object pool using this implementation. It's already working fine with prefabs but I don't know how to handle the recycling of particles system.

In my game when the main character picks stars I create a particle system by doing:

 GameObject explosion = Instantiate (explosionPrefab) as GameObject;
 explosion.transform.position = this.transform.position;

and after doing the emission it gets deleted because the Autodestruct flag is on.

I was looking for a method or someway to know when the particle emission finishes to call:

 ObjectPoolManager.DestroyPooled( explosion );


Any ideas?

Comment
Add comment · Show 2
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 GC1983 · May 03, 2012 at 07:08 PM 0
Share

Your question isnt very clear. $$anonymous$$ind elaborating what exactly you want it to do, in lamens...? =)

avatar image Macarse · May 03, 2012 at 07:13 PM 0
Share

I want to know where I should destroy the particle system. It should be done after the particle finishes emitting.

1 Reply

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

Answer by GC1983 · May 03, 2012 at 07:21 PM

There are three ways you could go about this depending on how you are using the object the particles are attached to:

  1. If you are keep the object after particles are executed, then just check the "One Shot" box in the particle options. It will set off the particles at one time, like an explosion, and not repeat it.

  2. If you are destroying the object after use, then it should destroy the particles with it, which automatically solves your issue. If youre not, label the particle object attached to the main object and send a Destroy() to that object.

  3. Or you could take this code and attach it to the particle object and sync the amount of time the particle emits to the timer that will destroy the object:

    var timeOut : int = 1.0; var detachChildren : boolean = false;

//Set timer to destroy function Awake () { Invoke ("DestroyNow", timeOut); }

//Destroy Object attached function DestroyNow () { if (detachChildren) { transform.DetachChildren (); } DestroyObject(gameObject);

This will automatically delete the particle object when you please.

Hope this helps!

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 Macarse · May 03, 2012 at 07:31 PM 0
Share

@Greg: 1) Careful. "One-shot" doesn't mean the particles are emitted only one time, it means the particles are emitted all at once ins$$anonymous$$d of over time. http://answers.unity3d.com/questions/46827/particle-emitter-to-emit-one-shot-on-specific-occa.html

2) The particle system might last longer than the object. For example the coin disappears before the explosion finishes.

3) This sounds like a good work around. I am not completely sure how to get the duration of the emission. How can I do that?

avatar image GC1983 · May 03, 2012 at 07:34 PM 0
Share

Ahh good point. Ill edit my answer. It still may solve his issue depending on the way the particles work. Ive used it for bomb explosions. $$anonymous$$y bad!

avatar image GC1983 · May 03, 2012 at 10:51 PM 0
Share

The duration is the $$anonymous$$ and maxEnergy. If you make them very small, it will make the emission very quick and short.

avatar image Macarse · May 03, 2012 at 11:34 PM 0
Share

@GC83: Cool. I will try it out. Thanks!

avatar image Macarse · May 04, 2012 at 03:12 PM 0
Share

It did work. 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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Recycling particle emitter leaves particles in 2 locations instead of 1 3 Answers

Turning on and off Particle effects 2 Answers

Android: FPS halt when doing things for the first time 2 Answers

Immortal enemies when reanimated, or pooled game objects re-activated do not respond to collisions? 1 Answer

Freeze lag with object pool/recycler, why? 2 Answers


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