Can anyone help me with a script to fire when the Player comes within range?
asked Apr 13 '10 at 06:41 PM
Use a trigger volume. Set up a spherical trigger collider around your enemy (by adding a sphere collider, then checking "Is Trigger". Then use OnTriggerEnter handler in your enemy's script to call your enemy's Fire function.
If you haven't yet made a Fire function at all, you should probably either Instantiate a projectile prefab, and set its rotation and velocity using the player's forward direction, or cast a ray in the player's forward direction and apply damage to whatever it hits.
answered Apr 13 '10 at 08:16 PM