- Home /
The question is answered, right answer was accepted
Horror Game Jump Scare Help
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?
Answer by RedCherryStudios · Aug 08, 2013 at 01:17 PM
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!
Follow this Question
Related Questions
Animation end trigger 1 Answer
How to perform a smooth push in the opposite direction of a wall 0 Answers
Character Fails To Jump Sometimes 1 Answer
Random Trigger placement? 1 Answer
play a door animation with collider 1 Answer