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
0
Question by Sach6536 · Dec 27, 2012 at 12:18 PM · fpshorror

How to add jumpscare sound effects when you looks enemy?

Hi! I am beginnig in unity, and I am making an horror game. I would like to add a jumpscare sound effect when the player is looking the enemy, like in movies, or games like scp 087-b or others. ( Sorry for my English) So, please can you tell me the script who can do that?

Happy hollydays.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Ben Ezard · Dec 27, 2012 at 02:04 PM

You can use: var enemy : GameObject; //the enemy
var soundEffect : AudioClip; //the sound effect that you want to be played when you see the enemy

function Update() {
if (enemy.renderer.isVisible && !audio.isPlaying) { //if the camera can see the enemy, and the sound effect isn't already playing
audio.clip = soundEffect; //assign the sound to the audio's clip
audio.Play(); //play the sound
}
}

Comment
Add comment · Show 10 · 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 Sach6536 · Dec 28, 2012 at 08:42 AM 0
Share

O$$anonymous$$ i am going to try, but please, can you tell me how to modify this sound?( I am null in scripts )

avatar image Ben Ezard · Dec 28, 2012 at 08:51 AM 0
Share

In the inspector view (the view where you can see stuff in your scene), click on the object that you've attached the script to You should see something like "Sound Effect: Audioclip (none)" under the name of the script - click on this, and then select the the sound effects that you want from the list that appears (you have to put it in the Assets folder first remember) Hope this helps, if you're still stuck t+en I can do a picture tutorial or something :)

avatar image Sach6536 · Dec 28, 2012 at 09:24 AM 0
Share

Really sorry,but I don't see it...

avatar image Ben Ezard · Dec 28, 2012 at 03:13 PM 0
Share

Here's a picture of what to do: http://ezardlabs.co.uk/images/Capture.PNG Also, replace your current script with the one above - I fixed something on it You'll also need to add an AudioSource component to the gameobject that has the jumpscare script attached

avatar image Sach6536 · Dec 30, 2012 at 02:58 PM 0
Share

"$$anonymous$$issingComponentException: There is no 'AudioSource' attached to the "$$anonymous$$ain Camera" game object, but a script is trying to access it. You probably need to add a AudioSource to the game object "$$anonymous$$ain Camera". Or your script needs to check if the component is attached before using it. JumpscareScript.Update () (at Assets/JumpscareScript.js:4)"

I don't really understand...

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

10 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

Related Questions

Shooting script problem. 2 Answers

Creating a walking animation. Need help! 1 Answer

How to make a house? 0 Answers

How to make a image flash infront of the camera 1 Answer

FPS Controller problems 4 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