|
Hi, This is the first time i am using the Unity dev kit. I am a sound designer. Now the question - How to create impact sounds in Unity ? I searched a bit but could not find an answer. What i am trying to do is add a sound to the barrel when player fires the gun at it.
* Please check the attachment. Or the pic - http://i47.tinypic.com/2wqcy6e.jpg
(comments are locked)
|
|
http://unity3d.com/support/documentation/Manual/Sound.html http://unity3d.com/support/documentation/Components/class-AudioListener.html http://unity3d.com/support/documentation/Components/class-AudioSource.html http://unity3d.com/support/documentation/ScriptReference/AudioSource.html http://www.unity3dstudent.com/2010/07/beginner-b10-audio-basics/ He also needs a mechanism. I don't know how the fire is handled in that game, but if bullets are instantiated you'll need to create a script that implement OnCollisionEnter, and if it's a Raycast you'll need to find where it's done and call a function there. A SendMessage would be a good idea. Light be hard if your not a programmer though.
Jun 24 '12 at 05:18 AM
Berenger
sry, was in a rush when I posted the links. Hopefully the docs were useful reading. I should've added you could get the hit position of a raycast (as @TheDavil86 suggested), then use AudioSource.PlayClipAtPoint at that position. This should be easy to add if you are using a raycast for the bullet, and for adding any effect at the point of impact (particle effect, audio). e.g.: Though I would consider instantianting an object at the impact point that includes a particle effect and audio clip (2 birds ....)
Jun 24 '12 at 07:09 AM
alucardj
thank you . i will try this and the other Raycast thing soon.
Jun 24 '12 at 10:20 AM
mixwell
(comments are locked)
|
|
You'll need to instantiate a sound at the collision point of the raycast. If you look at how the shooting code works you'll see there is a Physics.Raycast call. The 3rd argument in that function is usually tied to a variable of type RaycastHit. That RaycastHit variable will give you the position of the collision. And that's where you need to instantiate the sound. I'd just give you the code for it, but then you wouldn't really learn anything. I can try ! thanks
Jun 24 '12 at 05:52 AM
mixwell
(comments are locked)
|
|
@Jay Kay Thank you for that and i actually watched that JDAMS video before posting this. I applied that to my project but what it does it Play a sound when player "touches" the object. But what i am trying to create is impact (or collision in unity terms?) sounds. the impact is supposed to be the bullet which the player fires at the object. hi there, I have added a comment to my answer ( am Jay Kay =] ), please post comments using the comments tab [add new comment] under the answer.
Jun 24 '12 at 07:11 AM
alucardj
(comments are locked)
|


dude are you on soundsnap ?
no i don't have a soundsnap account. its for sfx right?
i don't need the actual sound files if thats what you mean.
Mix -- I just meant: since you are a sound designer, do you sell YOUR sound design work on http://SoundSnap.com ?
in answer to your question here. Are you familiar with the "Components" in Unity?
Your barrel will be a "GameObject".
What you want to do is add a "Component" to the barrel game object. In fact, what you'll want ot add is an "Audio Source".
Look at the AudioSource you have just added.
Notice - for example - there is a button "AutoPlay". try that. Whenever you launch, it will play. that's not what you want.
Now, you're going to have to learn a little scripting. You are comfortable with this? you will have to add a SCRIPT to the BARREL "game object". You write the scriupt and then drag it on. basically the script will say "when there is a collision, AudioSource.Play()" it's very easy if you're comfortable scripting.
Hope it helps, and ask anything.
oh. no i don't sell sfx there, however i am planning to do that soon.
and thanks for the tip.