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 coner · Dec 13, 2013 at 02:15 PM · videoaudiosourceaudiolistener

Figuring out multiple audio in scene

Hello,

I have three game objects. When the player collides with one, a video starts to play. However and normally editor says sth like "multiple audio source, you should need one". And video plays silent-no sound. How can I make it flowing smoothly? I need all video and sounds.

Platform is PC btw.

Comment
Add comment · Show 3
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 guitarxe · Dec 13, 2013 at 02:52 PM 1
Share

If you provide your code and details on how your objects are setup in the editor, we would be better able to assist you.

However, in general, if you want an audio clip to play when your player object collides with an obstacle you can put code on the obstacles that checks during collision if it has collided with the player object by using tags, and then if the tag is "player" (or whatever you set it to), then play the audio clip.

avatar image coner · Dec 13, 2013 at 03:12 PM 0
Share

     void OnTriggerEnter(Collider temas)
     {
         if (temas.gameObject.name.StartsWith("Player"))
         {
             flag = true;
         }
     }
 
     // Use this for initialization
     void Start ()
     {
         timer = 0;
     }
     
     // Update is called once per frame
     void Update ()
     {
         if (flag)
         {
             timer += Time.deltaTime;
         }
     }
 
     void OnGUI()
     {
         if (flag)
         {
             GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), cine_ask);
             cine_ask.Play();
             if (Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.Escape) || cine_ask.duration < timer)
             {
                 cine_ask.Stop();
                 Destroy(gameObject);
 
                 flag = false;
                 GameObject.FindGameObjectWithTag("guiOne").guiTexture.enabled = true;
             }
         }
     }
 }

As I said before there are three objects. And they have three different videos. So if I reduce these listeners to one, how can I assign video's audio?

avatar image guitarxe · Dec 13, 2013 at 03:46 PM 1
Share

@agostevethorne, you are incorrect. You can have as many audio sources in your scene as you want. It is the audio listener that you should have only one of, and it is by default already attached to the main camera.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by guitarxe · Dec 13, 2013 at 03:44 PM

I don't see any code here that even tries to play an audio clip.

Read up here

http://docs.unity3d.com/Documentation/Components/class-AudioClip.html http://docs.unity3d.com/Documentation/Components/comp-AudioGroup.html

And watch this video tutorial

http://unity3d.com/learn/tutorials/modules/beginner/audio/lessons/audio-sources-and-listeners

After having done so, try to first do it on your own, then if you are still having problems come back and describe what specific problem you are having.

Comment
Add comment · Show 6 · 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 coner · Dec 13, 2013 at 04:19 PM 0
Share

the video plays the audio. did you read the question or what?

avatar image guitarxe · Dec 13, 2013 at 04:35 PM 0
Share

Your question is not very clear, then. Why are you trying to play a different audio from what is already with the video?

avatar image Julien-Lynge · Dec 13, 2013 at 04:47 PM 0
Share

@guitarxe is right here and in his comment above.

The audio listener is like your player's ears. It tells Unity where sound volume and effects should be measured from for output to the speakers. You could certainly make an argument that Unity should allow multiple listeners - for instance, for a spy game where you want to be able to bug another room. But at least for now, that's the limitation.

Also, you should go and fix your question - you mention audio sources when you really mean audio listeners, and like @guitarxe I don't see any reference to audio in the code snippet you provided. You have code for playing cine_ask, but it's impossible to tell from what you've posted whether cine_ask is a $$anonymous$$ovieTexture or an AudioSource. $$anonymous$$eep in $$anonymous$$d that when you play a video it doesn't automatically play the audio track for the video - you have to extract it and play it separately.

Not a big deal - we just need good information if we're going to give you good answers.

avatar image coner · Dec 13, 2013 at 06:09 PM 0
Share

I am really shocked when I have seen your comments. It is very clear that I stated my problem is video related. Since my video have also audio, the editor did not like the situation. Because system needs audio listener for each audio source. Hence there are same number of listeners with number of video. At that point please ignore your wisdom and expertise.

Long story short; How can I assign each video's audio piece programmatically/on runtime? Thanks in advance.

avatar image Julien-Lynge · Dec 13, 2013 at 06:14 PM 0
Share

@coner,

I think you may be misunderstanding a few things about Unity. That's okay! We'll try to help you understand.

Because system needs audio listener for each audio source.

This is incorrect, and Unity will throw errors if you try this. There is only one audio listener regardless of the number of audio sources.

Since my video have also audio, the editor did not like the situation.

The problem is not that the editor does not like video that also has audio. The problem is somewhere else, and we're trying to figure out where. Are you extracting the audio for your video by using http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$ovieTexture-audioClip.html ? Are you then assigning the AudioClip to an AudioSource? Are you then calling Play() on the AudioSource?

Show more comments

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

18 People are following this question.

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

Related Questions

Passing Audio to an Android service? 0 Answers

3d Sound not working? 1 Answer

How to Switch The Audio Clip using button 0 Answers

Make Sound Effects Not Audible Unless Near Them 2d? 1 Answer

Mute 1 audio channel while preserving spatialized 3D sound? 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