- Home /
Enemy trigger for player
Hi all! My enemy shoots the ball continuously without stopping when I start playing. I wish that the enemy only when you start shooting within his field of vision. So I want to create a cube in which triggers when I enter the cube where is my enemy, he starts to shoot. I write a script trigger to my enemy? Thanks in advance. :-)
I tried to enter the enemy a sphere collider with the script but nothing triggers the enemy continues to shoot, then I popped up (trigger is) in the sphere collider. I tried again but nothing when I enter the sphere collider continues to shoot. I should add a tag to my enemy? Or some other script? Thank you.
Try giving the enemy a box collider with is trigger checked. Then add this script to the enemy:
function OnTriggerEnter (Trig : Collider) {
Debug.Log("Collider was triggered");
}
If it says Collider was triggered in the console then your trigger is working fine.. If it does work then try the same with a sphere collider :) However, like this it is triggered by any object and not just when the player goes within range of the collider. Also make sure that the player is actually inside the bounds of the collider.
Answer by lijrobert · Jan 16, 2012 at 02:28 AM
I would do a trigger script that when you collide with the cube http://unity3d.qatohost.com/questions/204670/trigger-other-objek-animation.html this triggers animation but it could easily trigger the firing of the enemy
Your answer
Follow this Question
Related Questions
Problem with the enemy 0 Answers
How an Enemy could activate a Sound? 3 Answers
Help needed! 1 Answer
enemy shoots with animation 1 Answer
Low gravity on trigger. 2 Answers