#pragma strict
var doorSound : AudioClip;
var newScene : String;
function Start()
{
if(Input.GetKey(KeyCode.E))
GetComponent.<AudioSource>().Play();
}
function Update(){
if(Input.GetKey(KeyCode.E))
{
Application.LoadLevel(newScene);
}
}
change update function by this
function Update(){
if(Input.GetKey(KeyCode.E))
{
GetComponent<AudioSource>().PlayOneShot(doorSound);
Application.LoadLevel(newScene);
}
}
Thanks mate! This worked. I have one issue though. my Audio Clip is a recording of a door opening and the after a second or two the sound of a door closing. It seems that the audio is cut of or ended after the new scene is loaded. I’s there anyway around this with making an audio trigger enter?