How to do it...

  1. Create the emitter class:
using UnityEngine; 
using System.Collections; 
using System.Collections.Generic; 
 
public class EmitterGraph : MonoBehaviour 
{ 
    // next steps 
} 
  1. Declare the member variables:
public int soundIntensity; 
public Graph soundGraph; 
public GameObject emitterObj; 
  1. Implement the validation of the emitter object's reference:
public void Start() 
{ 
    if (emitterObj == null) 
        emitterObj = gameObject; 
}
  1. Declare the function for emitting sounds:
public int[] Emit() 
{ 
    // next steps 
} 
  1. Declare and assign the variables needed:
List<int> nodeIds = new List<int>(); 
Queue<int> queue = new Queue<int>(); 
List<int> neighbours; 
int intensity = soundIntensity; 
int src = soundGraph.GetNearestVertex(emitterObj); 
  1. Add the ...

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.