I was wondering how can we enable it per particle.
Else, as my programmer friend suggested I have to give up the emission curve and emit a single particle so that he can instantiate the particle system and attach a sound to it.
Which will take away the freedom of randomly generated meteors :’(
So, what you actually want is a flying meteor, having a sound attached to it, after spawn? Then one sound playing on impact?
I would always create a prefab for the meteor then. With effects and sound and all. You can still spawn meteor prefabs via script randomly then. Random spawning in c# is one line of code
When using a separate prefab per meteor, you can also attach a collider to your prefab (which is adjustable in size and position) and get your collision events through the OnCollision of said collider, no need to use the particle collision then.
I guess I’m not clear with my explanation but if you place the emitter inside the collider I mentioned in line 2) with out mesh renderer so it will basically play sound every time a particle is birth.
void OnParticleCollision(GameObject colliderForBirth, Sound birthSound) {
Collider birth = colliderForBirth.GetComponent<Collider>();
if (birth) {
birthSound = GameObject.find("the emepty object with the sound").GetComponent<Sound>();
birthSound.Play().
}
}
Here for the kick start, I’m bored so I did for you in five second. that should live inside the script you attach to the GameObject with the PartcileSystem.
But there is one issue with this, I have created one invisible plane in front of my Meteor emitter, I already have collision ON for it, Now the particles are colliding with the invisible plane and exploding there (as I have other emitters on collision).
P.S. Particle trigger is the invisible plane and Particle collision is the collision mesh where I want it to explode.
but let me ask you a question regarding the whole technical architecture.
why you use particles as meteors? why not each meteor is an object which is modeled with a mesh . and particles will only be for the fill-up and effects? so it will be much better to performance be calculated only once by the CPU to create the meteor object and destroy it. instead of giving the GPU to calculate the particle behavior every frame ?
so I would suggest it to be efficient and smart.
model a meteor , or go to Houdini to generate some random models.
sit down with your programmer to design the code architecture and I would suggest to simplified it in the way @TobiasTobasco mentioned build a nice prefab that contains your particle system and the model with nice material and textures, and the script for the collision but this time it will talk about game object collision and not particles.
then with easy code you can instantiate the meteor prefab with a sound for birth and destroy it on hit with sound. its really easy and cheap performance wise. obviously you can control which direction it spawn that very simple code.
I guess you wanted to control the style of birth but I don’t think particle system are meant for that kind of goal.
live your artistic side for the nice textures. ribbons, derrises, light for heat and this kind of stuff to fill -up around that meteor.
and of course as well for the explosion of hit.
if you mean “just an environmental fx” like just to fill up in the background so particle system can do that. I thought at the beginning the focus is on the meteor like zoomed with detailed… but here I gave you two options.
Thanks for the detailed explanation, I 'll give it a try and update what worked the best for me.
It is just an environmental FX just to create some dramatic feel in the world