# Dispose a particle system

**URL:** <https://forum.babylonjs.com/t/dispose-a-particle-system/7317>\
**Category:** Questions\
**Created:** [December 1, 2019, 5:59pm UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317 "2019-12-01T17:59:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JFerret](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jferret/32/5541_2.png) [@JFerret](https://forum.babylonjs.com/u/JFerret)\
**Post date:** [December 1, 2019, 5:59pm UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317/1 "2019-12-01T17:59:36Z")

</div>

How do i dispose a particle system?

[https://www.babylonjs-playground.com/#1VGT5D#19](https://www.babylonjs-playground.com/#1VGT5D#19)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [December 1, 2019, 8:43pm UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317/2 "2019-12-01T20:43:29Z")

</div>

`ParticleHelper.CreateAsync` returns a Promise, not the system.

Use:

```javascript
    new BABYLON.ParticleHelper.CreateAsync("sun", scene).then((systems) => {
        //sphere.position.set(-2,0,0);
        systems.systems.forEach((system) => system.emitter = sphere);
        systems.start();
        //systems.dispose();
    });

```

[https://www.babylonjs-playground.com/#1VGT5D#21](https://www.babylonjs-playground.com/#1VGT5D#21)

---

<div class="post-metadata">

**Author:** ![JFerret](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jferret/32/5541_2.png) [@JFerret](https://forum.babylonjs.com/u/JFerret)\
**Post date:** [December 1, 2019, 10:05pm UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317/3 "2019-12-01T22:05:25Z")

</div>

I don’t understand.  
How can i dispose outside that function at a later time?

---

<div class="post-metadata">

**Author:** ![bigrig](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bigrig/32/5548_2.png) [@bigrig](https://forum.babylonjs.com/u/bigrig)\
**Post date:** [December 1, 2019, 10:22pm UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317/4 "2019-12-01T22:22:48Z")

</div>

You can assign it to a global variable and use that.

```auto
var mysystem;

    new BABYLON.ParticleHelper.CreateAsync("sun", scene).then((systems) => {
        systems.systems.forEach((system) => system.emitter = sphere);
        systems.start();
        mysystem = systems;
    });

//sometime later...
mysystem.dispose()

```

---

<div class="post-metadata">

**Author:** ![JFerret](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jferret/32/5541_2.png) [@JFerret](https://forum.babylonjs.com/u/JFerret)\
**Post date:** [December 1, 2019, 10:34pm UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317/5 "2019-12-01T22:34:01Z")

</div>

That’s it, thank you very much! 😃

---

<div class="post-metadata">

**Author:** ![Laureano](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/laureano/32/10237_2.png) [@Laureano](https://forum.babylonjs.com/u/Laureano)\
**Post date:** [November 17, 2021, 2:45am UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317/6 "2021-11-17T02:45:09Z")

</div>

Hi there?  
Did that work for you?  
If I use it that way , outSide the {} it gives me an Error.

But if I use mysystem.dispose(); inside the { } it works just fine…  
…

---

<div class="post-metadata">

**Author:** ![11128](https://avatars.discourse-cdn.com/v4/letter/1/d07c76/32.png) [@11128](https://forum.babylonjs.com/u/11128)\
**Post date:** [November 17, 2021, 9:55am UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317/7 "2021-11-17T09:55:45Z")

</div>

hello @Laureano  
i think your error is maybe

1. var mysystem ; (it is undefined)
2. and create Particle , set up mysystem = particle
3. Then an error, because the wait callback was not called or not called on success (When your logic calls before mysystem.dispose() is finished) you call mysystem.dispose() This may be an undefined error.  
and using parameter systemsed(it is variable) instead of systems

[https://www.babylonjs-playground.com/#1VGT5D#54](https://www.babylonjs-playground.com/#1VGT5D#54)

---

<div class="post-metadata">

**Author:** ![Laureano](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/laureano/32/10237_2.png) [@Laureano](https://forum.babylonjs.com/u/Laureano)\
**Post date:** [November 22, 2021, 6:14pm UTC](https://forum.babylonjs.com/t/dispose-a-particle-system/7317/8 "2021-11-22T18:14:40Z")

</div>

thanks a lot for your adice!  
Your answered helped me a lot…  
I just realized that I was calling it to fast, and couldn’t find the partcles. like they wern’t created yet.

So I found a solution doing something like this.

```auto
if (systemsed!=undefined){
        systemsed.dispose();
    }

```
