I have a prefab Shuriken Particle system & I want it to follow a rock after it collides.
Problems I have with this
1.I can get the particles to turn on when I want but not turn off as I can’t access the prefab Shuriken emission.
2.I can’t gett it to follow the rock the this script is attached to only be created where it collides. I think I need an update function but I don’t know how to fit that in below.
Thanks for any help.
var Debris : GameObject;
function OnCollisionEnter(){
Instantiate(Debris, transform.position, transform.rotation);
Emit particles for 3 seconds
yield WaitForSeconds(3);
//Then stop
Debris.enableEmission = false;
}
When “Debris” is your prefab, you might want to save the actual instantiated object which is returned by the “Instantiate” function. You can then access it’s components like transform or the particle system.
var actualObject : GameObject = Instantiate(Debris, transform.position, transform.rotation);
// Wait...
actualObject.transform.postion.x += 10; // move it
actualObject.transform.particleEmitter.enabled = false;; // stop the emitter