- Home /
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... :) 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!!
I have been looking for the same thing and tried to make soooo many scripts even though I have no idea how to make scripts. That is how badly I need this.
Ok thanks but now to says object reference not set to an instance of an object. How could I fix that? This error is at line 11. Thanks for the help
sounds like you didnt do this portion.
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.
im guessing you didnt actually define what slenderman was by going in and dragging the slenderman prefab over to the script and dropping into over the word slenderman so it knows what slenderman is.
With the questions you are asking, it is a little worrying. First, is your project in C# or JS? It is possible but you really shouldn't use them mixed, mainly for compilation order reasons.
Second, are you using my guide or have written your own script? If so, this raycast is already done as part of the isVisible check. So if isVisible, play sound.
If you are just starting out, here are some links I strongly suggest to all new users, the unity3Dstudent videos are only maximum 5 $$anonymous$$utes long each so really quick to do and learn =]
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/essential-skills/
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/beginner/
this is the YouTube link for the above as one playlist : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp
the Unity Wiki : http://wiki.unity3d.com/index.php/Tutorials
A list of resources : http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html
Helpful page with information on using Built-In Arrays and Lists :
The unity wiki link above is very handy with lots of scripts and shaders too (just check out all the links down the left, and the tabs along the top : http://wiki.unity3d.com/index.php/Scripts )
Ok, I'll go check these out!! And just to clarify, I am using your script, and when I copied it in, I copied it into a C# Script... The only problem I'm having is the stinking Slenderman Prefap won't drag over to the Script Slenderman Variable (So it knows what "Slenderman" is.) Everything is going smooth, it's just that stupid dragging problem... Thanks again..
Answer by sparkzbarca · Nov 08, 2012 at 01:13 AM
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.
let me know if it throws errors or something isnt working i'll try to help.
I got a error saying the name does not match the name of the class defined in the script. Have any ideas?
yea i gave it the default name you must have changed it. public class NewBehaviourScript
NewBehaviorScript has to match the name of the script
so if say the name of the script is ScaredYa
the line should be
public class ScaredYa :$$anonymous$$onoScript {
it has to be an exact copy.
I also got an eof error at line 17 but found a left brace. i got an unexpected token: ) on line 10. i got a expecting ) but found ray cast at line 10. There's a ';' expected. Insert semicolon at the end. On line 7. There's an unexpected token: game object on line 6. An unexpected token : a brace facing the right on line 4. An unexpected token: :. On line 4. And expected. There's a ';' expected. Insert semicolon at the end on line 2. And a ';' expected. Insert a semicolon at the end on line 1. I know that's a lot to tackle but can anyone help. I would really appreciate it. Thanks.