|
I tried using ParticleSystem.SetParticles to change the lifetime of a particle, but it reset the other particles. Is there a way to simply destroy / hide / move one particle without resetting the system?
(comments are locked)
|
|
What exactly did you do? As with the old system, I would guess you first have to get all current particles with ParticleSystem.GetParticles, then remove the particle you want from that array somehow, and then reassign that new array back to the ParticleSystem (but read on). In the old particle system (ParticleEmitter), instead of removing the particle physically from the array, it was enough to set its energy to 0. This way the ParticleEmitter will take care of the rest, recognize the particle als being dead/finished, and remove it itself from its internal particle array. I would assume you can do the same with Shuriken? EDIT: I tested this now for myself. The Shuriken works the same as the old system, you can modify/remove/add individual particles. BUT the API call to get the existing particles is just plain weird and stupid, I have no idea why anyone would program it in such a way: Instead of simply returning the particles array, which you then can modify, you must provide your own array, which is passed to GetParticles(). After this call returns, your particles array has been filled with the information of the existing ParticleSystem. This is completely unintuitive, and would probably be frowned upon and discouraged in any programming guide, to call a function "GetXXX", but then have it modify an array you have to initialize and pass into it. tl;dr: Try this example instead, it will work. Create a new ParticleSystem with default emission behaviour, and attach this script to it. (Note, when using the menu GameObject->CreateOther->ParticleSystem, the ParticleSystem will initially have an x=270 rotation, for whatever reason) This appears to do nothing...
Jun 22 '12 at 08:35 PM
Essential
You need to reassign the particle system. particleSystem.SetParticles(particles,particles.length)
Jun 22 '12 at 08:42 PM
Loius
Yeah that's my problem Vicenti. When I do that, the particle system resets. What I'm trying to achieve is a set of orbs that bounce out that the player can collect. They'll bounce out fine and will slowly disappear over the lifetime rate, and I can detect when a player has collected a particle. I just don't know how to make that individual particle disappear. Using SetParticles the particles all bounce out all over the place again and reset the lifespan.
Jun 23 '12 at 04:36 AM
Essential
Well, in the code fragment you posted you are creating an empty array of particles, so there won't be happening much. Usually, this array is initialized by the ParticleSystem. If you create your particles entirely by yourself, generate an empty array as you did, fill it with your desired values (without using GetParticles!), and then apply it with SetParticles, all this in some initialization routine such as Start(). Note that your code fragment shouldn't compile, since there is no property "lifespan", it is called "lifetime". Also note that in your code you set the first particle's lifetime to 0, so the ParticleSystem will automatically remove it before the next Update. This reduces the length of your particles array by one, and at a starting size of 7 you should be almost immediately run into an "array out of bounds" error.
Jun 25 '12 at 03:47 PM
Wolfram
(comments are locked)
|
|
So the more I research this, the more I'm beginning to believe that it's impossible to adjust the properties of a settled particle without the whole particle system starting the animation from scratch. If anyone could just confirm this that would be great. Then I can start investigating another option for my bouncing collectable coins... see my edited answer
Jun 26 '12 at 10:20 PM
Wolfram
(comments are locked)
|
