I am currently working on a horror game and my goal is to have the player step in a trigger and cause something to appear play a sound auto like a scream or something and disappear, what exactly would be the best way of doing this?
Create a empty object and apply a collider of your choice e.g. a box collider. Next scale it to suit your needs and set it as trigger. Afterwards set your players tag to “Player” and then apply your script to the collider.
var exampleObject : GameObject;
function OnTriggerStay(hit:Collider){
if(hit.gameObject.tag == "Player"){
exampleObject.animation.Play("ExampleAnimation");
}
}
This will play the animation of the example object. Make sure to rename “ExampleAnimation”
var exampleObject : GameObject;
function OnTriggerStay(hit:Collider){
if(hit.gameObject.tag == "Player"){
exampleObject.audio.Play("ExampleAudio");
}
}
This will play the audio of the example object. Make sure to rename “ExampleAudio”
*This is my first time answering so i hope this helps!