Visual artifacts with Trail Meshes

Hello.
I’m getting strange visual artifacts when using trail meshes.
Trail Mesh Documentation

I want to spawn a sphere from one character and shoot it towards another with a trail.
However I get a strange black trail popping up from the zero position of the scene to the position of the sphere as you can see in this playground:
https://playground.babylonjs.com/#D6MGWV#1

When I set the position of the sphere to the start position before attaching the trail however the behavior is even stranger.
https://playground.babylonjs.com/#D6MGWV#2

Additional question:
Is there a way to have the trail end more smoothly?
When I use trail.stop() it just freezes and when i dispose it it just disappears immediately.
When i just let it stay active you can see a weird quad.

image

You should not set the position of the sphere before calling bakeCurrentTransformIntoVertices but after:

https://playground.babylonjs.com/#D6MGWV#3

Also, the quad is the shape created by the trail mesh when generating the effect. You can try to keep the sphere visible until the trail disappears completely, as in the PG above.

You can also scale the sphere down until the end of the anim:

https://playground.babylonjs.com/#31XP9U#5

4 Likes

Perfect solution!
Thank you so much :smiley: