|
Can anyone help me with a script to fire when the Player comes within range?
(comments are locked)
|
|
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. The only problem is that a bunch of bullets spray out instead of one if(disPlayer.magnitude < 7){ fire(); } } }
Apr 16 '10 at 11:01 PM
Persona
(comments are locked)
|
