How do I Update the transform of Instantiate prefab?

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

Something along this, perhaps.

Sorry guys this is really hard for me to get my head around as I’m an artist not a coder. So try to make it as simple as poss. Thanks for the help!

So I have a prefab called Debris & an animated Rock you saying to put the script on the prefab instead of the rock to access the the components of it?

I tried this but got an error…
Assets/Scripts/Prefab Scripts/Rock_Debris.js(1,45): BCE0005: Unknown identifier: ‘Rock_Particle_Debris’.

var actualObject : GameObject = Instantiate(Rock_Particle_Debris, transform.position, transform.rotation);
// Wait…
actualObject.transform.postion.x += 10; // move it
actualObject.transform.particleEmitter.enabled = false;; // stop the emitter