- Home /
Particles dissapearing when camera is close
Hello. I was trying to copy the Procedural Examples for a convincing lightning bolt particle effect. I noticed that it was using legacy particles, the ParticleEmitter, so I was trying to update it to use the ParticleSystem. I realize I'll have to post a bit of code here, so I apologize for the size:
Awake() of the particles:
void Awake () { oneOverZigs = 1f / (float)zigs;
gameObject.particleSystem.enableEmission = false;
particles = new ParticleSystem.Particle[zigs];
//particleSystem.GetParticles (particles);
noise = new Perlin ();
emit (false);
}
emit of the particles:
public override void emit (bool shouldEmit)
{
this.shouldEmit = shouldEmit;
if (shouldEmit)
{
curTime = 0.0f;
particleSystem.Emit (zigs);
} else
{
particleSystem.Clear ();
}
}
Lastly, Update of the particles:
void Update ()
{
if (shouldEmit)
{
curTime += Time.deltaTime;
if (curTime > duration || source == null || dest == null)
{
recycle ();
return;
}
float timex = Time.time * speed * 0.1365143f;
float timey = Time.time * speed * 1.21688f;
float timez = Time.time * speed * 2.5564f;
for (int i=0; i < zigs; i++)
{
Vector3 position = Vector3.Lerp (source.position, dest.position, oneOverZigs * (float)i);
Vector3 offset = new Vector3 (noise.Noise (timex + position.x, timex + position.y, timex + position.z),
noise.Noise (timey + position.x, timey + position.y, timey + position.z),
noise.Noise (timez + position.x, timez + position.y, timez + position.z));
position += (offset * scale * ((float)i * oneOverZigs));
particles [i].position = position;
particles [i].color = Color.white;
particles [i].size = 0.20f;
}
//particleEmitter.particles = particles;
particleSystem.SetParticles (particles, particles.Length);
}
}
}
This works just fine... until I noticed that if I zoom in even modestly close to the particles (particles might take up... a square centimeter on the screen) they completely disappear! I've tried messing with Maximum Size in the renderer of the Particle System to no avail. I'm not getting anywhere near close enough for the camera to be "going through" or past these particles, Im quite far away. It's very strange to see them work fine from a very far distance but as soon as I zoom just a little they all disappear. Any help would be appreciated, thanks!
Pictures... Far enough away: Too close:
You can see the particle emitters in scene view in the second image, but no graphics. You can see the graphics in the first image, just a little further away.
Edit: It should be noted that the Shuriken particle system works just fine when I don't manually assign particle positions like I do in the above script. I use many particle effects and it doesn't matter where the camera is, I can still see them. It's just with these procedurally generated/manipulated particles that I'm having what seems to be clipping issues. Thanks again for any assistance.
Edit 2: It seems to be the direction the camera is facing too... If Im looking "east", I can zoom quite far up to the particles, but if im looking west, i have to zoom out much much further to see them. This is both in scene view and camera view. Maybe that would give a hint to the problem?
I did yes, but thanks for your reply! I wish I could post a video, it's truly very bizarre. They work great from far away but get close and the scene view just shows the particle system objects without emission, but you zoom out and it's emitting like it never stopped.
Very recently I was trying to write a pointcloud component using Shuriken. I eventually came to the conclusion (like many others) that the Shuriken ParticleSystem is buggy, unfinished and unreliable.
Are you able to recreate your particles using a ParticleEmitter ins$$anonymous$$d?
Sorry, I just woke up! I've re-read your question and it looks like you're trying to do something very similar to a point cloud.
I would ask: were your particles working with the ParticleEmitter? Why are you "updating" to ParticleSystem?
You're welcome to my PointCloud component: http://pastebin.com/Z7sF3RJD
Indeed, I've been busy so I haven't gotten around to reverting but yes - just like in the original Procedural Examples code, the ParticleEmitter DOES work with absolutely no issues. The reason I was "updating" was I thought ParticleEmitter was essentially deprecated. So I believe I will just revert to particle emitter and having it work fine. The pointcloud component you mention sounds very interesting, programmatically controlling the particle system for a mathematical simulation. I may download that code and try it out, thank you for the link. But yes I've come to the conclusion that Shuriken is bugged as nobody seems to be able to give me a valid answer as to why the particles randomly disappear. Thanks for your time Vesuvian!
Answer by Budgieboy · May 04, 2014 at 06:47 PM
Try changing the clipping planes on the camera, have the near plane set to something like -5 and see if that works.
Yep! It's clamped at 0.01 (If you want go to behind the camera, just move the camera back I would assume is the logic). It doesn't seem to work :-/. Thank you for the suggestion though!
Your answer
Follow this Question
Related Questions
Destroy particles based on bounds not lifetime 0 Answers
turn on off particle system 1 Answer
A whip like particle system 1 Answer