• 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 Andrew_m_aus · Jan 17, 2013 at 04:53 AM · lightingenemyshadow

Two questions to long for title

ok i know the title is stupied but its true my questions are to long.

  1. can I make it so if my enemy is in a certin range it plays certine whipering (creepy) sounds

  2. can I also make it so if my flashlight (spotlight) shines on my enemy it disapers and stops the sound or makes it louder 3.thanks in advance if you can help people

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
2
Best Answer

Answer by cdrandin · Jan 17, 2013 at 05:03 AM

Yes and yes. Quite simple thanks to Unity.

This will just be pseudocode, but it should work

1) Assume target as a Transform type. This script is attached to the player. if Vector3.Distance(transform.position, target.position) < 20 //assume 20 meters within range then Play creepy sound. Place sound on target. Send a message and have the target contain a function which receives a signal when to play this sound.

2) Use a spotlight and modify it to your liking then put it in front of this flashlight object. Then create a RayCast pointing out of the flashlight point to check for collision and if the collision hits this "monster" tag, meaning our target, then have the script call the target's play sound function and increase the sound or w/e. You can make the functions unique by passing in parameter for how loud or change in frequency. For this look up RayCast and HitRayCast in the Unity docs.

Comment
Add comment · Show 3 · 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 Andrew_m_aus · Jan 17, 2013 at 06:03 AM 0
Share

thanks very much im a nood with scripting could you give me a link to any examples, like in the unity wiki or something like that??? thanks again

avatar image cdrandin · Jan 17, 2013 at 07:50 PM 1
Share
  • http://www.youtube.com/playlist?list=PL11F87EB39F84E292

  • http://www.youtube.com/user/InsurgentXdotcom?feature=watch

  • http://walkerboystudio.com/html/unity_training___free__.html#unity3javaScript

avatar image Andrew_m_aus · Jan 18, 2013 at 09:46 AM 0
Share

tanks very much for the help

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

9 People are following this question.

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

Related Questions

Directional Light creates wierd shadow? 2 Answers

Issue with realtime shadows (receive shadows) 1 Answer

Toon Shader Working With Multiple Spotlight Shadows (Pro) 0 Answers

Lightmapping Darkness & Lightmapped Hard/Soft Shadows 0 Answers

Problem with shadows 1 Answer


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