Can somebody help me out with a jumpscare? (Like from the game "Slender")

I am fairly new to Unity3d and I need some help from the masters… :slight_smile: I am creating a Slender game in Unity3d (for those of you who don’t know what what Slender is, it’s a first person survival horror game in which you are being chased by Slenderman, who is a tall man with no face.) In the game Slender, whenever you see Slenderman it makes a loud noise (jumpscare.) In my remake of this game, I am trying to figure out how to create this effect. How do I make it so whenever you look at Slenderman it makes a loud noise? (Slenderman is just a 3d model from the internet) I realize this will require a script and I am just asking for some help with it. Thank you guys so much for helping me out with this dilemma! I REALLY appreciate it!!

attach a sound o to slender man (component–>audio–>audio source)

raycast towards the front of the player
if the object hit is slenderman play the sound file

this should be the script basically (its an easy script)

//attach this to the player object 
//its in C#
//i'm making alot of stuff drag and drop
//so you can just drop in your stuff in the 
//editor to make it work.


using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

	public GameObject slenderman;
	RaycastHit raycast;
	
	void Update () {
	Physics.Raycast(transform.position,transform.forward, out raycast);
		if(raycast.transform.gameObject == slenderman)
		{
			slenderman.audio.Play();
		}
		
	}
}

Now you take this script which you created and after you build and run it in the script editor thing. You go back into unity and click on the script. it will now have a variable you can change on the right called slenderman. You take your slenderman Prefab and you drag and drop that onto it so the script knows what slenderman is.

it will cast a ray in front of the player and if it is slenderman it will play the audio attached to slenderman.

That means you also need to attach an audio component to the slenderman.