|
How can I adjust audio volume based on how close the player gets to a game object? Please let me know. Thank you!
(comments are locked)
|
|
define your player's distance from the object and tell it to play when he gets within range: for instance... something like this would be attached to your game object. Make sure your game object has an audio source on it and a clip attached.. otherwise assign a clip in code. I'll do that here... Thank you for the help! I tested this code out also and it say player is not defined as a variable so i added var player; and it stopped the errors but i don't think the script is actually doing anything because my sound plays exactly the same when I'm close to the gameobject and when I'm far from the gameobject. Unfortunately Unity's 3D sound isn't giving me the effect I'm looking for. Maybe I'm doing something wrong? Please help if you can. i appreciate it!
Jun 05 '12 at 11:05 PM
shawnkilian
yes sorry I should have noted this is just an idea to work off of. Post what you currently have and let me know exactly what you want to happen... specifics and I'll get it working for you. JS or C# is fine
Jun 06 '12 at 05:09 PM
stingman
(comments are locked)
|
|
Well, that's the point of a 3D sound. Sounds quite when far from the listener and loud when next to it. But, if you want to do this by script you can add a script to the gameobject which has an audio source and do some coding like: C# code: Thank you for your help! I tried out the C# code and it gives me an error on the first line public Transform target; Thoughts?
Jun 05 '12 at 11:03 PM
shawnkilian
(comments are locked)
|
