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 Xpadrian2010 · Dec 13, 2015 at 03:54 PM · multiplayerfpssoundaudiolistenersnapshot

AudioMixer Snapshot Problem

Hello!

I'm doing a multiplayer game and I wonder how I can make the following effect:

https://www.youtube.com/watch?v=FNqFMCa6KQM

I was thinking of doing different snapshots, audio Mixer, and with a script to do that when the audiolistener is located at a certain distance to change the snapshot on the other, I tried that but I can't get it.

I hope soon to be fixed thank you sorry if my English is bad.

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 Xpadrian2010 · Dec 12, 2015 at 07:31 AM 0
Share

I created a script that makes changing from one snapshot to another when a GameObject is a certain distance, the problem is that there are many players and the script only takes into account only one of them (because is a $$anonymous$$ultiplayer game) and others not, so for those players do not change the snapshots, if anyone knows how to fix it please respond.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.Audio;
 
 public class Sound : $$anonymous$$onoBehaviour {
     public Transform target;
     private Transform myTransform;
     public Audio$$anonymous$$ixerSnapshot Snapshot1;
     public Audio$$anonymous$$ixerSnapshot Snapshot2;
     public Audio$$anonymous$$ixerSnapshot Snapshot3;
     public Audio$$anonymous$$ixerSnapshot Snapshot4;
     public Audio$$anonymous$$ixerSnapshot Snapshot5;
 
     void Awake()
     {
         myTransform = transform;
     }
     
     // Use this for initialization
     void Start ()
     {
         GameObject go = GameObject.FindWithTag("Player");
         target = go.transform;
     }
     
     // Update is called once per frame
     void Update ()
     {
         float dist = Vector3.Distance(target.position, transform.position);
         if (dist >= 0)
         {
             Snapshot1.TransitionTo(0.01f);
         }
         if (dist >= 10)
         {
             Snapshot2.TransitionTo(0.01f);
         }
         if (dist >= 15)
         {
             Snapshot3.TransitionTo(0.01f);
         }
         if (dist >= 20)
         {
             Snapshot4.TransitionTo(0.01f);
         }
         if (dist >= 30)
         {
             Snapshot5.TransitionTo(0.01f);
         }
     }
 }
 

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by boombostak · Apr 07, 2016 at 10:40 AM

Hi @Xpadrian2010 ,

Try AudioMixer.TransitionToSnapshots and use the distance to determine weights. Here is part of the code to do a similar thing using points in space (nodes) that are associated with a snapshot.

 for (int i = 0; i < node_array.Length; i++) {
             closenesses[i] = 1/
                 Vector3.Distance(node_array[i].transform.position, 
                                  target.transform.position);
 
 public void BlendSnapshots()
         {
             mixer.TransitionToSnapshots (snapshot_array, distances_to_nodes_array, 0.005f);
         }

This weights the transition based on irregularly spaced nodes. For your problem you would either want to have only 2 snapshots (very close and very far) and blend between them, or figure out a way to set your weights based on specific intervals of distance from the source (if it's in 5 meter intervals, maybe testing if distance%5==0). Hope this helps.

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

FPS, Trying to add sound to footsteps, Not working! 2 Answers

Check if RaycastAll hits[i].point == null 0 Answers

Remove first element of array 1 Answer

How to make a camera work in this circumstance. 1 Answer

Database connection FPS game? 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