InAudio Documentation

Advanced Audio Plugin for Unity

User Tools

Site Tools


Random footsteps

For this example we are creating a random node with three different sound clips and with some variations to give make every sound unique.

Open the Audio & Event windows from Window/InAudio in the Unity toolbar.
Right click on the Root folder and create the 'Random' child node.

Now find your variations of this sound and drag them on the created 'Random' node. In this case there are three different sounds clips. Multiple clips can be dragged simultaneously and 'Audio' nodes will created with the respective names.

To add more variation to the footsteps, a small amount of randomness is added to the volume and pitch. A very small delay variation could also be added as well as a change in the weights of the nodes. Not pictured is the option to avoid playing the X last sounds to avoid playing the same number twice.

Open the Event window and create an event by right clicking on a folder. Drag the 'Footstep' node onto the created event. As can be see at second circle, a 'Play' event is automatically created and the 'Footstep' node assigned to it.

Now, create a script, add the following code and attach it to a gameobject.

using UnityEngine;
public class FootstepExample : MonoBehaviour {
       public InAudioEvent FootstepEvents; 
	void Update () {
	    if (Input.GetKeyDown(KeyCode.F))
                //The gameobject that controls the sounds & the events to be posted
	        InAudio.PostEvent(gameObject, FootstepEvents);

Drag and drop the footstep event onto the inspector and press play! Now every time you press F a unique footstep sound will be played.

examples/footsteps.txt · Last modified: 2015/07/08 23:29 by peterolsted