for my game I’m making it so you walk into a trigger, a sound plays, you turn around and there is something there. I have managed to get the object to spawn but it is way outside my map, how can I set it to the position I want? Here is the script.
var prefab : Transform;
private var soundPlayed : boolean = false;
var Laugh : AudioClip;
var volume: float = 10.45;
var LightOff : AudioClip;
var ObjToDestroy : Light;
var ObjToDestroy2 : Light;
var ObjToDestroy3 : Light;
var ObjToDestroy4 : Light;
var ObjToDestroy5 : Light;
var ObjToDestroy6 : Light;
var ObjToDestroy7 : GameObject;
function OnTriggerEnter(col : Collider){ //Play Sound if player enters trigger
if (!soundPlayed && Laugh) { // but only if it has not played before
AudioSource.PlayClipAtPoint(Laugh, transform.position, 10.4);
soundPlayed = true; // sound will not play anymore
audio.PlayOneShot(LightOff);
Destroy (ObjToDestroy);
Destroy (ObjToDestroy2);
Destroy (ObjToDestroy3);
Destroy (ObjToDestroy4);
Destroy (ObjToDestroy5);
Destroy (ObjToDestroy6);
Destroy (ObjToDestroy7);
Instantiate (prefab);
}
}