Editing Positions of a Particle System (Sub Emitter)
Hey guys this is my first question ever posted on here. Thanks for taking the time to read it!
I'm creating a shooting game of sorts. When I hit an object I have an existing particle system that does the default particles just to resemble that I've hit my target. Once these particles die, I make them subEmit a RED particle. So if I hit a target 5 white particles will pop out, after x seconds, each white particle emits a red particle.
Now where I have my problem is the RED particles will NOT fly to my designated position. Depending on impact height they will fly according to where that height is. Horizontal distance reacts in the same fashion. I've even tried creating an empty game object under my scrolling camera to grab the transform.position of it. The screen is going to the right at a static 0.05f. I don't know why or where it is taking into account where the impact has happened since no where in my code does it use such data. Here is what I have so far:
void LateUpdate() { //increment it forward with the screen destination += new Vector3(0.05f, 0, 0); ParticleSystem.Particle[] ParticleList = new ParticleSystem.Particle[m_currentParticleEffect.particleCount]; m_currentParticleEffect.GetParticles(ParticleList); for (int i = 0; i < ParticleList.Length; ++i){ //calculate the particles current position to destination -> vector dir dir = destination - ParticleList[i].position; //if the particle is already near/on the destination then dont bother editing position if(dir.magnitude > 0.02){ //multiply it by .05f to not make the 'velocity' too high dir *= 0.5f; //add dir to current pos of particles ParticleList[i].position += dir; } } //set the particles m_currentParticleEffect.SetParticles(ParticleList, m_currentParticleEffect.particleCount); }
Thanks again for the help and your time!
Your answer
Follow this Question
Related Questions
setting a particle system to overwrite old particles, to make way for the new? 1 Answer
Move a separate object forward on collision between particle system and another object 0 Answers
How does ParticleSystem.Particle.velocity behave? 0 Answers
Fade particle emission rate over time 0 Answers
I am having trouble getting these effects to work on Android! Can someone please help me? 0 Answers