- Home /
Shooting Projectiles Script supposed to delete Projectile, not the parented Particle System
I have a Projectile Script which spawns a sphere in the player camera (with Rigidbody) I made a Prefab and this Prefab is instantiated inside the player cam every time I press LeftMouseButton And this Prefab has 2 components: The sphere and the particle system. The script is supposed to delete only the sphere, not the Particle System. I wanted to stop emitting particles after the sphere is gone (so that it looks better like now), but every time the particles just disappear right when the sphere is deleted and this looks a bit weird If you can help me solve this problem, I would be very thankful, but please keep in mind that I'm new to programming, so could you please explain it to me as newbie-style as you could (If that word even exists, but you get my point)
Answer by lefinno · Jun 01, 2017 at 01:46 PM
you can first stop the particle emitting first (ParticleSystem.Stop) first and delay for a while and delete the whole thing.
cus once you deleted the parent, all of it's child will be deleted too.(sounds dark)
Answer by centaurianmudpig · May 30, 2017 at 08:06 AM
I haven't used the ParticleSystem, so take this with a grain of salt; I presume you have attached your particle system directly to the Projectile as a prefab. When you destroy the projectile the particles are destroyed because they are attached to the destroyed object.
You want to either put the projectile in a limbo state, that the projectile is active in the scene but does not render the prefab, whilst it completes the animation. Or add the ParticleSystem as a child to the projectile and detach when the projectile is destroyed using Transform.SetParent().
Answer by Tu-Le · May 30, 2017 at 06:54 AM
dont exactly know what you mean but remember getmousedown meaning you only run it once time when you hold down your mouse.
Your answer
Follow this Question
Related Questions
ParticleSystem is not emitting particles. 0 Answers
How to force a particle system emit from every vertex a mesh have? 3 Answers
Emit particles from image/sprite 1 Answer
Particle system won't restart emitting before last particle has died 3 Answers
Can a Particle System Use Custom Objects/Prefabs as Particles? 1 Answer