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 :slight_smile:

Its the same script “Save” Shared but i have added Audio For a scarier Feel :slight_smile:

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.

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
}