Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ADAMN721 · Mar 21, 2017 at 01:56 AM · networkingaudiosource

UNet Audio Help

I feel I may just not have a solid understanding of how this SHOULD work and I am approaching it the wrong way..

What I am looking to achieve is a gun shot sound that plays for the local player as it should(meaning it sounds like it was fired from the local gun). Then, have that same gun shot sound be heard by all other players within a certain area and drop off depending on how far away they are.

Right now I have it partially working. I can either have it sound perfect for local or for other players. I am having trouble accomplishing both.

The question I am confused on is... if the audio source plays the clip and that is where the settings for whether it's 2d or 3d and fade distance blah blah blah, how can this sound correct for both a local player and other networked players. A local player should require it to be played as a 2d clip with play and a networked player needs to hear it as a 3d clip using playclipatpoint.

Obv I know this can be done... Please tell me what I am missing... Here is code below to demonstrate how I am calling this currently. I have a fairly long command method calling this. I didn't care to paste because it's not relevant. This is the way that allow other players to hear fine but it sounds strange locally.

  [ClientRpc]
     void RpcPlayFireSound(Vector3 GunShotPosition, string WeaponName)
     {
       AudioClip WepSound =  GetComponent<WeaponSounds>().ReturnWepSound(WeaponName);
         AudioSource.PlayClipAtPoint(WepSound, GunShotPosition);
     }

Comment
Add comment · Show 1
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 ADAMN721 · Mar 21, 2017 at 03:40 PM 0
Share

Anyone have any sort of insight on this?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AurimasBlazulionis · Mar 21, 2017 at 04:20 PM

You would want to set the audio to 2D in OnStartLocalPlayer function, using AudioSource.spatialBlend. So the code would look like this:

 public override void OnStartLocalPlayer () {
     referenceToAudioSource.spatialBlend = 0f;
 }

Just change referenceToAudioSource to whatever name you use for the audio source.

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Audio listeners in multiplayer game 3 Answers

Live Audio 0 Answers

Unity networking tutorial? 6 Answers

How do i stream music from a server? 0 Answers

Character Customization in Pun 2 2 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