We will create the SoundReceiver class for our agents, and SoundEmitter for things such as alarms:
- Create the class for the sound-receiver object:
using UnityEngine; using System.Collections; public class SoundReceiver : MonoBehaviour { public float soundThreshold; }
- Define the function for the behavior that is handling the reception of sound:
public virtual void Receive(float intensity, Vector3 position) { // TODO // code your own behaviour here }
- Now, let's create the class for the sound-emitter object:
using UnityEngine; using System.Collections; using System.Collections.Generic; public class SoundEmitter : MonoBehaviour { public float soundIntensity; public float soundAttenuation; public GameObject emitterObject; ...