Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-1
Question by Peanut97 · Nov 07, 2012 at 11:14 PM · gameobject

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!!

Comment
Add comment · Show 8
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GameCreat3r · Nov 07, 2012 at 11:26 PM 0
Share

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.

avatar image GameCreat3r · Nov 08, 2012 at 11:14 PM 0
Share

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

avatar image sparkzbarca · Nov 09, 2012 at 12:38 AM 0
Share

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.

avatar image AlucardJay · Nov 09, 2012 at 02:59 AM 0
Share

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 :

http://www.unifycommunity.com/wiki/index.php?title=Which_$$anonymous$$ind_Of_Array_Or_Collection_Should_I_Use?

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 )

avatar image Peanut97 · Nov 09, 2012 at 03:17 AM 0
Share

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..

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 14 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Peanut97 · Nov 08, 2012 at 02:05 AM 0
Share

Thanks, $$anonymous$$an! It means a lot!

avatar image sparkzbarca · Nov 08, 2012 at 02:17 AM 0
Share

let me know if it throws errors or something isnt working i'll try to help.

avatar image GameCreat3r · Nov 08, 2012 at 03:20 AM 0
Share

I got a error saying the name does not match the name of the class defined in the script. Have any ideas?

avatar image sparkzbarca · Nov 08, 2012 at 03:43 AM 0
Share

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.

avatar image GameCreat3r · Nov 08, 2012 at 03:52 AM 0
Share

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.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Unity Editor Function Animation 0 Answers

How to destroy object forever? when i go to another scene and back to first, i want to that object stay destroyed! , Please !!!!  1 Answer

Script gives wrong rotation. 1 Answer

Unity3D Pressure Plate request. 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges