Search Unity

Audio There are 38 audio listeners in the scene. Please ensure there is always exactly one audio listener

Discussion in 'Audio & Video' started by Pokemonkillspery, Jun 28, 2018.

  1. Pokemonkillspery

    Pokemonkillspery

    Joined:
    Jun 28, 2018
    Posts:
    1
    okay so im not really sure whats going on but and i cant find a solution for it so ive come here so im working on a procedural generation script for a but when i finished up and went to test it i got a message in the consol saying that There are 38 audio listeners in the scene. Please ensure there is always exactly one audio listener and it locked up my players movement so i could only look side to side but not up and down and ive tried to find the other audio listeners but i can find them and the only "camera" is the player

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class WorlldGeneration : MonoBehaviour {
    6.  
    7.     public GameObject player;
    8.  
    9.     public int sizeX;
    10.     public int sizeZ;
    11.  
    12.     public int groundHeight;
    13.     public float terDetail;
    14.     public float terHeight;
    15.     int seed;
    16.  
    17.     public GameObject[] blocks;
    18.  
    19.     // Use this for initialization
    20.     void Start() {
    21.         seed = Random.Range(100000, 999999);
    22.         GenerateTerrain();
    23.     }
    24.  
    25.     // Update is called once per frame
    26.     void Update() {
    27.  
    28.     }
    29.  
    30.     void GenerateTerrain() {
    31.         for (int x = 0; x < sizeX; x++) {
    32.             for (int z = 0; z < sizeZ; z++) {
    33.  
    34.                 int maxY = (int)(Mathf.PerlinNoise((x / 2 + seed) / terDetail, (z / 2 + seed) / terDetail) * terHeight);
    35.                 maxY += groundHeight;
    36.  
    37.                 GameObject grass = Instantiate(blocks[0], new Vector3(x, maxY, z), Quaternion.identity) as GameObject;
    38.                 grass.transform.SetParent(GameObject.FindGameObjectWithTag("Environment").transform);
    39.  
    40.                 for (int y = 0; y < maxY; y++) {
    41.                     int dirtLayers = Random.Range(1, 5);
    42.                     if (y >= maxY - dirtLayers) {
    43.                         GameObject dirt = Instantiate(blocks[2], new Vector3(x, y, z), Quaternion.identity) as GameObject;
    44.                         dirt.transform.SetParent(GameObject.FindGameObjectWithTag("Environment").transform);
    45.                     }else {
    46.  
    47.                         GameObject stone = Instantiate(blocks[1], new Vector3(x, y, z), Quaternion.identity) as GameObject;
    48.                         stone.transform.SetParent(GameObject.FindGameObjectWithTag("Environment").transform);
    49.                     }
    50.  
    51.                     if (x == (int)(sizeX / 2) && z == (int)(sizeZ / 2)) {
    52.                         Instantiate(player, new Vector3(x, maxY + 3, z), Quaternion.identity);
    53.                     }
    54.                 }
    55.             }
    56.  
    57.  
    58.         }
    59.     }
    60. }
     
  2. jmp909

    jmp909

    Joined:
    Jun 29, 2018
    Posts:
    3
    that seems odd

    i would do the following

    1) put a Debug.Log inside GenerateTerrain.. check it is only called once
    2) put a Debug.Log just before Instantiate player. check it is only called once
    3) take out Instantiate player, see if the warnings are still there
    4) take out the whole GenerateTerrain code, see if the warnings are still there

    it's the only way you're going to start to isolate the problem

    to me it sounds like it's not even related to this script. what's your code controlling the player's movement etc
     
  3. Docaroo

    Docaroo

    Joined:
    Nov 7, 2017
    Posts:
    82
    Try everything in the post above first ... If you aren't generating an audiolistener from script and it's just attached to the player object in your hierarchy then you must be generating 38 instances of that player object somehow for this to happen! The debug logs should help narrow that down!

    I just realise you don't mention where you have set the audiolistener or its parent to be so find where you are doing that.