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 mixwell · Jun 24, 2012 at 04:40 AM · audiosound effectssfx

How to create impact sounds?

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.

*What i ended up doing is this (which is not what i want) - http://www.mediafire.com/?y48bfxt5hb9ey2m


Please check the attachment.alt text

Or the pic - http://i47.tinypic.com/2wqcy6e.jpg

  • Thanks.

Comment
Add comment · Show 4
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 Fattie · Jun 24, 2012 at 10:00 AM 0
Share

dude are you on soundsnap ?

avatar image mixwell · Jun 24, 2012 at 10:17 AM 0
Share

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.

avatar image Fattie · Jun 24, 2012 at 10:39 AM 0
Share

$$anonymous$$ix -- I just meant: since you are a sound designer, do you sell YOUR sound design work on 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.

avatar image mixwell · Jun 25, 2012 at 05:38 AM 0
Share

oh. no i don't sell sfx there, however i am planning to do that soon.

and thanks for the tip.

3 Replies

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

Answer by AlucardJay · Jun 24, 2012 at 04:46 AM

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/

http://www.youtube.com/watch?v=fIGEPFjm4xQ

http://www.gameaudio101.com/Unity-Audio-Tips.php

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 Berenger · Jun 24, 2012 at 05:18 AM 0
Share

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 Send$$anonymous$$essage would be a good idea. Light be hard if your not a programmer though.

avatar image AlucardJay · Jun 24, 2012 at 07:09 AM 0
Share

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

 public var impactClip : AudioClip;
 
 function Update()
 {
     if (Input.Get$$anonymous$$ouseButtonUp(0))
     {
         var ray = Camera.main.ScreenPointToRay( Input.mousePosition );
         var hit : RaycastHit;
         if ( Physics.Raycast(ray, hit, 100) ) 
         {
             AudioSource.PlayClipAtPoint( impactClip, hit.point );
         }
     }
 }

Though I would consider instantianting an object at the impact point that includes a particle effect and audio clip (2 birds ....)

avatar image mixwell · Jun 24, 2012 at 10:20 AM 0
Share

thank you . i will try this and the other Raycast thing soon.

avatar image
0

Answer by TheDavil86 · Jun 24, 2012 at 05:39 AM

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.

Comment
Add comment · Show 1 · 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 mixwell · Jun 24, 2012 at 05:52 AM 0
Share

I can try ! thanks

avatar image
0

Answer by mixwell · Jun 24, 2012 at 05:39 AM

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

Comment
Add comment · Show 1 · 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 AlucardJay · Jun 24, 2012 at 07:11 AM 0
Share

hi there, I have added a comment to my answer ( am $$anonymous$$ $$anonymous$$ay =] ), please post comments using the comments tab [add new comment] under the answer.

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

7 People are following this question.

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

Related Questions

One Slider Control More Than One Sound 1 Answer

Button doesn't play sound after different button press 0 Answers

Separate Listeners for Sound FX and Music? 0 Answers

Sound plays right at the beginning 2 Answers

Problems with a racing game level. 0 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