- Home /
[solved] Enemy aggressive when point "flashlight" to him
Hi, i'm using a flashlight model with a Directional Light attached to it, and I have a enemy in the game, I need to make this: If I point flashlight to him, it attacks me.
you should have a collider in the directional light, and when the enemy enters the light it triggers a event. look at triggers and collision.
Please check my question as answered if this is what you wanted glad to help.
Answer by Chris12345 · Aug 04, 2012 at 04:16 PM
this is an example for you, hope this helps. function React was the message sent to run this first script.
#pragma strict
function React () {
animation.Play("whateveryoucalledyouranimation");
//or//
animation.CrossFade ("attackanimation");
else
animation.CrossFade ("idleanimation");
}
script 2
this code triggers it.
#pragma strict
function OnCollisionEnter(col : Collision) {
if(col.gameObject.name == "objectcollidenamehere"){
gameObject.Find("objecttosendmessageto").SendMessage("React");
}
}
Script 1 is attached to camera or Spot Light? (Sorry is Spot Light)
Edit: I don't have a shooting enemy, it's a horror game, attack is: Enemy come to my position walking fast, animate the Attack animation, I take damage.
script one is on your character that has the flash light and collider for the character to hit.
Your answer
Follow this Question
Related Questions
Make spotlight flicker when seeing enemy? 1 Answer
Problem with Flashlight in Horror Game 2 Answers
Photon Spawn on server, not client 0 Answers
How do I stop a function from executing? 1 Answer
Trap Door Question 1 Answer