# Custom particle update of position has no effect

**URL:** https://forum.babylonjs.com/t/custom-particle-update-of-position-has-no-effect/47302
**Category:** Questions
**Tags:** particles
**Created:** [January 17, 2024, 6:58pm UTC](https://forum.babylonjs.com/t/custom-particle-update-of-position-has-no-effect/47302 "2024-01-17T18:58:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)
#### Post date: [January 17, 2024, 6:58pm UTC](https://forum.babylonjs.com/t/custom-particle-update-of-position-has-no-effect/47302/1 "2024-01-17T18:58:09Z")

</div>

Hello everyone!

I have been toying with particle systems and it seems the custom update function has no effect:

> **[Babylon.js Playground](https://playground.babylonjs.com/#EAZYXZ%2373)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

I managed to make the stretching effect from [How to create a Particle Stretch Effect for Warp Speed](https://forum.babylonjs.com/t/how-to-create-a-particle-stretch-effect-for-warp-speed/16920) in a simpler way by using `BILLBOARDMODE_STRETCHED` for the particles instead of changing the angle.

In this playground I have a spaceship (the cube focused by the camera) that is going through the warp tunnel and the emitter of the tunnel (the other cube).

As the emitter is attached to the spaceship, particles world velocity are their initial velocity plus the velocity of the spaceship.

This is problematic because the effect breaks down rapidly when the velocity of the ship increases.

This could be mitigated by using `isLocal=true` for the particle system but then the tunnel would behave unnaturaly when rotating the spaceship (with IJKL) as their would be no bending of the trajectory of the particles.

What I want to do is artificially remove the velocity of the spaceship by updating the positions of the particles each frame. Subtracting the displacement of the ship should do the trick I think.

I am trying to change the positions in the `onBeforeRenderObservable` and I am not getting a lot of success.

I also tried using a custom update function but it also seems to have no effect.

Does someone know what I am doing wrong here?

---

<div class="post-metadata">

### Author: ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)
#### Post date: [January 17, 2024, 11:51pm UTC](https://forum.babylonjs.com/t/custom-particle-update-of-position-has-no-effect/47302/2 "2024-01-17T23:51:09Z")

</div>

Let me add @Evgeni_Popov who built the warp particles of the previous post 🙂

---

<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: [January 18, 2024, 11:10am UTC](https://forum.babylonjs.com/t/custom-particle-update-of-position-has-no-effect/47302/3 "2024-01-18T11:10:44Z")

</div>

I tried a number of things but could not come up with a solution…

Maybe @PatrickRyan will have some ideas?

---

<div class="post-metadata">

### Author: ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)
#### Post date: [January 18, 2024, 12:03pm UTC](https://forum.babylonjs.com/t/custom-particle-update-of-position-has-no-effect/47302/4 "2024-01-18T12:03:28Z")

</div>

Thanks for trying!

I commented the entire body of the custom update function and… nothing changed? Except for the fact that the particle recycling was not handled and therefore the effect eventually stops.

> **[Babylon.js Playground](https://playground.babylonjs.com/#EAZYXZ%2374)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

This is so weird, maybe the cylinder emitter overrides the position of the particles?

---

<div class="post-metadata">

### Author: ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)
#### Post date: [January 18, 2024, 12:16pm UTC](https://forum.babylonjs.com/t/custom-particle-update-of-position-has-no-effect/47302/5 "2024-01-18T12:16:24Z")

</div>

I removed the cylinder emitter and still I can’t change the positions of the particles 😕

> **[Babylon.js Playground](https://playground.babylonjs.com/#EAZYXZ%2376)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

### Author: ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)
#### Post date: [January 22, 2024, 2:51pm UTC](https://forum.babylonjs.com/t/custom-particle-update-of-position-has-no-effect/47302/6 "2024-01-22T14:51:12Z")

</div>

Okay I finally fixed it!

> **[Babylon.js Playground](https://playground.babylonjs.com/#EAZYXZ%2381)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Basically I needed to use `onBeforeParticlesRenderingObservable` and update the particles there. The other issue was also that I computed the anchor displacement for each particle which is completely dumb and my bad ^^’
