Spawning a projectile with a trigger

Im trying to make a projectile spawn from a turret when an “enemy” tagged object enters its collider or trigger zone. I have 2 empty game objects positioned where I would like the projectiles to spawn from and I also have the projectile ready to go as a prefab. I’ve been trying to come up with a script myself but I can’t seem to get it to work so far. Any help with this code would be greatly appreciated!
Steve

Steve,

It would go something like this. Create 3 public GameObject variables in your script that you will assign values to in the editor. Assign the spawn point A to one variable, spawn point B to one variable, then assign the prefab to the third variable.

Within your script, add an OnCollisionEnter() or OnCollisionEnter2D() method, and create the missile at whichever spawn point you want using the Instantiate method, passing the starting point as the spawn point. You can pass Quaternion.identity for no rotation.

For further reading: