- Home /
How to make a image flash infront of the camera
Thanks to "Save" This issue has been resolved. But i would like to post the script in this main Section so i can help other people with the same problem :)
Its the same script "Save" Shared but i have added Audio For a scarier Feel :)
 var trollImage : GUITexture;
 var Scream : AudioClip;
 
 function Start () {
     trollImage.enabled = false;
 }
 
 function OnTriggerEnter () {
     audio.clip = Scream;
     audio.Play();
     trollImage.enabled = true;
     while (trollImage.color.a>0) {
        trollImage.color.a-=1*Time.deltaTime;
        yield;
     } 
 }
Have Fun! Thank you heaps "Save"
Sound repeats if you walk through again.. Not to sure how to fix that sorry.
Answer by save · Sep 20, 2012 at 10:27 AM
Create a GUITexture (GameObject > Create Other > GUI Texture).
On the trigger place a script something like this and assign the trollImage in Inspector,
 var trollImage : GUITexture;
 
 function Start () {
     trollImage.enabled = false;
 }
 
 function OnTriggerEnter () {
     trollImage.enabled = true;
     //Add audio and other logic here
     while (trollImage.color.a>0) {
         trollImage.color.a-=1*Time.deltaTime;
         yield;
     }
     collider.enabled = false; //Disables the collider so event only happens once
 }
No worries! I assumed that you only wanted this to happen once so I added a boolean for disabling it the second time. You could also at the last line inside OnTriggerEnter disable the collider or the GameObject holding the collider.
$$anonymous$$ate... Thank you So much!!! It worked it actually freaked me out i wasn't expecting it to :P thank you! :)
Haha! Then you know you've succeeded if you get frightened of your own creation. Hope you live through the rest of production! :-)
Will do mate.. You just made my game more freaky! appreciate it... I shall now have a terrifying "image" at a few doors :D thanks again
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                