- Home /
Particle System playing spontaneously
First I have to say, that I consider myself still a beginner, when it comes to the Unity-Software.
A Particle-System called "engineParticles" is attached to my Player. Whenever I am moving the player by using the dedicated joystick, the particlesystem should play to simulate exhaust from the player´s thrusters, which works perfectly.
public class PlayerMovement : MonoBehaviour
{
public ParticleSystem engineParticles;
void Update()
{
if (joystickMovement.isUsed)
{
if (!engineParticles.isPlaying)
engineParticles.Play();
}
else
engineParticles.Stop();
}
}
The problem occurs when a different GameObject is instantiated as a child to the player, which also holds a Particle-System. In this particular case this object is a missile. Its Particle-System is supposed to play only when a "launch" function is called. This is also the case, but apart from that the Particle-System of the missile also plays while the Particle-System "engineParticles" is playing.
First I assumed that the code somehow confuses both Particle-Systems. But this is not the case as both Particle-System are specificly assigned in the editor and not during runtime. When more detailed information including code is needed, please tell and I will provide it!
Edit:
I have not managed to solve the issue to this day. But, I thought also this could be just a visual bug or something that only appears in the editor, but that is not the case, since I have exported and built the project to iOS where the "bug" still is persistent.
Furthermore, I checked whether the ParticleSystem of the missile is really playing by checking its isPlaying state, which equalled true .
So, one solution was to deactivate this ParticleSystem (missileParticleSystem.Stop()) every FixedUpdate call. This is of course not a solution I can live with as it still does not solve the underlying problem.
One solution I accepted, was to attach the ParticleSystem of the missile to an empty GameObject, which I then disabled and enabled when the ParticleSystem needed to be played.
Because this does not solve the underlying issue, I don´t think it is the time to close this question. And I am still open for any ideas.