- Home /
Question by
blackpantherxx · Sep 23, 2012 at 02:41 PM ·
enemylightspotlightflashlightflicker
Make spotlight flicker when seeing enemy?
My enemy is tagged "enemy". And i want to have my spotlight flicker when seeing enemy. Is there any way to do this?
Comment
Best Answer
Answer by save · Sep 23, 2012 at 02:52 PM
//Enemy script
function OnBecameVisible () {
Spotlight.Flicker();
}
//Spotlight script
static var spotlight : Light;
function Start () {
spotlight = GetComponent(Light);
}
static function Flicker () {
for (var i = 0; i<5; i++) {
spotlight.enabled=!spotlight.enabled;
yield WaitForSeconds(.05);
}
spotlight.enabled = true;
}
Your answer
Follow this Question
Related Questions
Flashlight battery script 3 Answers
How do I get my flashlight to work? 1 Answer
Spotlight Piercing through game objects? 0 Answers
Help with my Light Flicker Script... 1 Answer
Low shadow quality from distance light 2 Answers