Dynamically adding a particle emitter?

I’m actually having quite a big of trouble with this. My question is best explained with a quick and random example.

I have a scene where the user can create water pipes by touching and dragging the screen. There water pipes are simply cylinders that are dynamically added whenever the user creates them.

Now, later on, say the user can trigger something, spring a leak, shoot the pipe, or anything to get the water to shoot out. I want this done with a particle emitter so when the triggered, attach a particle emitter to a position on the cylinder and then of course be able to then remove that particle after a certain time (say after the water runs out).

I looked at a few examples but they were pretty confusing. Any ideas on how to do this with C#?

you would create a water effect prefab thats all setup for your use and then use GameObject.Instantiate( someRef, … ) where someRef is a public Transform someRef and you dropped the water effect prefab in.

the … in the function are position and rotation that you need to set accordingly.

to remove it again you naturally would have to store the return in a global place

shouldnt be much of a problem, Id suggest making a prefab of your emitter object and instatiating it at the right position.

Edit: Too late :slight_smile:

Yea here’s what I kind of don’t understand. I created a prefab and everything but I just don’t understand the public transform. What is that public transform and how does it know what the particle emitter is.