<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tutorial on DAD 424 Sound Design for Games</title><link>https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/tags/tutorial/</link><description>Recent content in Tutorial on DAD 424 Sound Design for Games</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Mon, 13 Oct 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/tags/tutorial/index.xml" rel="self" type="application/rss+xml"/><item><title>Simplifying Sound Playback in Unity with FMOD’s PlayOneShot Command</title><link>https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/lectures/week-8/using-playoneshot/</link><pubDate>Mon, 13 Oct 2025 00:00:00 +0000</pubDate><guid>https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/lectures/week-8/using-playoneshot/</guid><description>Learn how to use FMOD’s PlayOneShot and PlayOneShotAttached commands in Unity to efficiently trigger one-off sound effects through colliders and triggers.</description><content>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>In game audio, efficiency matters. When designing sound interactions in Unity using FMOD, there are many cases where you only need a sound to play once—like when a player picks up an item or activates a switch. Writing full event-handling code for each instance can quickly become cumbersome.&lt;/p>
&lt;p>That’s where FMOD’s &lt;strong>PlayOneShot&lt;/strong> command comes in. This function provides a fast, elegant way to trigger short, non-looping sound effects in your game world without manually managing event instances. In this guide, we’ll walk through how to use &lt;strong>PlayOneShot&lt;/strong> and &lt;strong>PlayOneShotAttached&lt;/strong>, explain how Unity’s trigger system ties in, and unpack key technical concepts like Vectors, Colliders, and Layers.&lt;/p>
&lt;hr>
&lt;h2 id="what-is-playoneshot">What Is PlayOneShot?&lt;/h2>
&lt;p>FMOD’s &lt;code>PlayOneShot&lt;/code> command allows you to play an FMOD event anywhere in your game with a single line of code. When the command is called, it automatically plays the event and then cleans up after itself when the sound finishes—no need to store or release the event manually.&lt;/p>
&lt;p>This makes it ideal for simple, one-off sound effects such as button clicks, weapon pickups, or door openings.&lt;/p>
&lt;p>For instance, if we want to trigger a short sound effect when a player picks up their melee weapon, &lt;code>PlayOneShot&lt;/code> lets us do it with minimal setup.&lt;/p>
&lt;hr>
&lt;h2 id="setting-up-the-event-in-fmod">Setting Up the Event in FMOD&lt;/h2>
&lt;ol>
&lt;li>&lt;strong>Create a new 3D Action event&lt;/strong> called &lt;code>Staff Collect&lt;/code> and add your audio file (for example, &lt;code>Switch Activated 01&lt;/code>).&lt;/li>
&lt;li>Assign the event to your &lt;strong>Master Bank&lt;/strong>.&lt;/li>
&lt;li>Organize it neatly under &lt;strong>SFX → Interactables&lt;/strong>.&lt;/li>
&lt;li>Save your project and &lt;strong>build your banks&lt;/strong>.&lt;/li>
&lt;/ol>
&lt;p>Once you’ve done that, switch back to Unity to implement the sound event.&lt;/p>
&lt;blockquote>
&lt;p>Action Events are perfect for short, non-looping sounds that play once and then stop. They are typically used for sound effects triggered by player actions or environmental events.&lt;/p>
&lt;/blockquote>
&lt;p>&lt;img src="https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/f-25-dad-424-sound-design-for-games/lectures/week-8/using-playoneshot/image.png">&lt;/p>
&lt;hr>
&lt;h2 id="using-triggers-in-unity">Using Triggers in Unity&lt;/h2>
&lt;p>A &lt;strong>Trigger&lt;/strong> in Unity is an invisible area that detects when objects (like your player) enter or leave it. Triggers are built using colliders with the &lt;strong>Is Trigger&lt;/strong> box checked. When something passes through, Unity can perform specific actions—such as playing a sound.&lt;/p>
&lt;p>For our weapon pickup example:&lt;/p>
&lt;ul>
&lt;li>The &lt;code>StaffTakeTrigger&lt;/code> object in your scene will act as the trigger.&lt;/li>
&lt;li>It already has a &lt;strong>Sphere Collider&lt;/strong> attached with &lt;strong>Is Trigger&lt;/strong> enabled.&lt;/li>
&lt;li>When the player enters this area, Unity can detect the interaction and execute our FMOD command.&lt;/li>
&lt;/ul>
&lt;p>We’ll connect this trigger to our FMOD event using a custom script.&lt;/p>
&lt;hr>
&lt;h2 id="writing-the-trigger-script">Writing the Trigger Script&lt;/h2>
&lt;p>Go to your &lt;code>FMOD Scripts&lt;/code> folder and create a new C# script called &lt;code>F_StaffCollectTrigger&lt;/code> attach it to the &lt;code>StaffTakeTrigger&lt;/code> object.&lt;/p>
&lt;p>Delete the default &lt;code>Start&lt;/code> and &lt;code>Update&lt;/code> functions, as we won’t need them for this simple interaction.&lt;/p>
&lt;p>Inside the script, we’ll use the &lt;code>OnTriggerEnter&lt;/code> function. This Unity event function runs automatically when another object enters the trigger’s collider.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-csharp" data-lang="csharp">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">using&lt;/span> UnityEngine;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">public&lt;/span> &lt;span style="color:#66d9ef">class&lt;/span> &lt;span style="color:#a6e22e">F_StaffCollectTrigger&lt;/span> : MonoBehaviour
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">void&lt;/span> OnTriggerEnter()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> FMODUnity.RuntimeManager.PlayOneShot(&lt;span style="color:#e6db74">&amp;#34;event:/SFX/Interactables/StaffCollect&amp;#34;&lt;/span>, transform.position);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;blockquote>
&lt;p>&lt;code>onTriggerExit&lt;/code> is another useful function that runs when an object leaves the trigger area. You can use it for sounds that should play when the player exits, like a door closing. &lt;code>onTriggerStay&lt;/code> runs continuously while an object remains within the trigger.&lt;/p>
&lt;/blockquote>
&lt;p>This is all it takes to trigger the &lt;em>Staff Collect&lt;/em> sound effect when the player enters the area.&lt;/p>
&lt;p>However, we can improve this setup by specifying &lt;em>where&lt;/em> in 3D space the sound should be played.&lt;/p>
&lt;hr>
&lt;h2 id="understanding-vectors-in-unity">Understanding Vectors in Unity&lt;/h2>
&lt;p>To position sounds accurately, we need to work with &lt;strong>Vectors&lt;/strong>—data types that store coordinates and direction.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Vector2&lt;/strong> holds &lt;em>x&lt;/em> and &lt;em>y&lt;/em> coordinates (useful for 2D games).&lt;/li>
&lt;li>&lt;strong>Vector3&lt;/strong> holds &lt;em>x&lt;/em>, &lt;em>y&lt;/em>, and &lt;em>z&lt;/em> coordinates (used in 3D games).&lt;/li>
&lt;/ul>
&lt;p>In Unity, almost every object’s position, rotation, and scale are stored as Vector3 values. To access the current position of your object, you can reference its &lt;strong>Transform&lt;/strong> component.&lt;/p>
&lt;blockquote>
&lt;p>Here, &lt;code>transform.position&lt;/code> retrieves the Vector3 position of the object this script is attached to (the trigger). This is shorthand for &lt;code>GetComponent&amp;lt;Transform&amp;gt;().position&lt;/code>.&lt;/p>
&lt;/blockquote>
&lt;p>If you want to play the sound at a different location but related to the trigger, you can create a new Vector3:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-csharp" data-lang="csharp">&lt;span style="display:flex;">&lt;span>Vector3 pos = transform.position + Vector3.up * &lt;span style="color:#ae81ff">1.5f&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>FMODUnity.RuntimeManager.PlayOneShot(&lt;span style="color:#e6db74">&amp;#34;event:/SFX/Interactables/StaffCollect&amp;#34;&lt;/span>, pos);
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This example plays the sound 1.5 units above the trigger’s position.&lt;/p>
&lt;hr>
&lt;h2 id="layers-and-collision-setup">Layers and Collision Setup&lt;/h2>
&lt;p>For the trigger to work correctly, Unity needs to detect when the player enters the trigger area. This requires proper setup of &lt;strong>Layers&lt;/strong> and &lt;strong>Colliders&lt;/strong>.&lt;/p>
&lt;ol>
&lt;li>The object acting as the trigger must have a collider with &lt;strong>Is Trigger&lt;/strong> checked.&lt;/li>
&lt;li>The player object must either:
&lt;ul>
&lt;li>Have a &lt;strong>Rigidbody&lt;/strong> component, or&lt;/li>
&lt;li>Be on a layer compatible with the trigger’s layer.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;p>You can manage these interactions in Unity’s &lt;strong>Layer Collision Matrix&lt;/strong> under &lt;em>Edit → Project Settings → Physics&lt;/em>.
Ensure that the &lt;strong>Player&lt;/strong> layer can interact with the &lt;strong>Environment&lt;/strong> layer (or whichever layer your trigger belongs to).&lt;/p>
&lt;blockquote>
&lt;p>Tags and Layers help organize objects in your scene and control how they interact. Tags are used for identifying objects, while Layers are used for collision detection and rendering.&lt;/p>
&lt;/blockquote>
&lt;p>&lt;img src="https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/f-25-dad-424-sound-design-for-games/lectures/week-8/using-playoneshot/physics-layers.png">&lt;/p>
&lt;p>Here you can see the Layer Collision Matrix in Unity, which defines how different layers interact with each other. See that the &lt;strong>Player&lt;/strong> layer can collide with the &lt;strong>Environment&lt;/strong> layer, allowing our trigger to detect when the player enters.&lt;/p>
&lt;hr>
&lt;h2 id="using-playoneshotattached">Using PlayOneShotAttached&lt;/h2>
&lt;p>While &lt;code>PlayOneShot&lt;/code> requires a position vector, FMOD also offers a variant called &lt;code>PlayOneShotAttached&lt;/code>. This version automatically plays an event at the location of a specific game object.&lt;/p>
&lt;p>Here’s how to use it:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-csharp" data-lang="csharp">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">void&lt;/span> OnTriggerEnter()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> FMODUnity.RuntimeManager.PlayOneShotAttached(&lt;span style="color:#e6db74">&amp;#34;event:/SFX/Interactables/StaffCollect&amp;#34;&lt;/span>, gameObject);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The &lt;code>gameObject&lt;/code> reference points to the object this script is attached to—in this case, &lt;code>StaffTakeTrigger&lt;/code>.
This makes it an elegant alternative when you want to link the sound directly to an object’s position.&lt;/p>
&lt;p>If you want to attach the sound to another object in the scene, you can define a &lt;strong>public GameObject variable&lt;/strong> in your script and assign it through the Unity Inspector:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-csharp" data-lang="csharp">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">public&lt;/span> GameObject Obj;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">void&lt;/span> OnTriggerEnter()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> FMODUnity.RuntimeManager.PlayOneShotAttached(&lt;span style="color:#e6db74">&amp;#34;event:/SFX/Interactables/StaffCollect&amp;#34;&lt;/span>, Obj);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This approach provides flexibility for triggering sounds from different points in your game world.&lt;/p>
&lt;hr>
&lt;h2 id="limitations-and-next-steps">Limitations and Next Steps&lt;/h2>
&lt;p>While &lt;code>PlayOneShot&lt;/code> and &lt;code>PlayOneShotAttached&lt;/code> are great for quick, lightweight sound triggers, they come with a limitation:
you can’t manipulate FMOD parameters after triggering them.&lt;/p>
&lt;p>For cases where you need to control parameters dynamically (for instance, changing pitch or volume in response to player movement), you’ll need to use full event instances instead.&lt;/p>
&lt;p>We’ll explore this in the next module: &lt;strong>Interacting with FMOD Parameters&lt;/strong>—where you’ll learn how to adjust event behavior in real time for adaptive sound design.&lt;/p>
&lt;hr>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>The &lt;code>PlayOneShot&lt;/code> and &lt;code>PlayOneShotAttached&lt;/code> commands streamline the process of triggering short, non-looping sounds in Unity. Combined with Unity’s trigger system and a solid understanding of Vectors and Layers, they allow you to quickly prototype interactive sound behaviors.&lt;/p></content></item><item><title>Attaching Audio to Animations with FMOD and Unity</title><link>https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/lectures/week-9/attaching-audio-to-animations/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/lectures/week-9/attaching-audio-to-animations/</guid><description>Introduction This post walks through a practical pipeline for triggering FMOD sound events from Unity Animation Events so your character’s footsteps, landings, and swishes line up precisely with what’s on screen. We’ll build a reusable C# function that can be called from any Animation Event and, later, accept the FMOD event path as a parameter—setting us up to drive parameters (like surface material) in a follow-up lesson.
What You’ll Build An FMOD event for a footstep, with a Material parameter that selects between multiple surface types.</description><content>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>This post walks through a practical pipeline for triggering FMOD sound events from Unity Animation Events so your character’s footsteps, landings, and swishes line up precisely with what’s on screen. We’ll build a reusable C# function that can be called from any Animation Event and, later, accept the FMOD event path as a parameter—setting us up to drive parameters (like surface material) in a follow-up lesson.&lt;/p>
&lt;hr>
&lt;h2 id="what-youll-build">What You’ll Build&lt;/h2>
&lt;ul>
&lt;li>An FMOD event for a footstep, with a &lt;code>Material&lt;/code> parameter that selects between multiple surface types.&lt;/li>
&lt;li>A Unity C# function that:
&lt;ul>
&lt;li>Creates and attaches an FMOD event instance to the player at runtime,&lt;/li>
&lt;li>Starts the event,&lt;/li>
&lt;li>Releases the instance,&lt;/li>
&lt;li>Accepts a string parameter for the FMOD event path (so you can reuse it across many animations).&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Animation Events in Unity that call your C# function exactly when each foot hits the ground.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="fmod-setup-a-single-footstep-event-many-materials">FMOD Setup: A Single Footstep Event, Many Materials&lt;/h2>
&lt;p>Create a 3D event named &lt;code>Ellen_Run&lt;/code> in the &lt;code>SFX/Ellen&lt;/code> folder that plays one footstep per trigger.&lt;/p>
&lt;p>Add a user parameter named &lt;code>Material&lt;/code> and set it to Hold (so the footstep that already triggered won’t switch mid-play if the parameter changes). Add four values representing different surface types:&lt;/p>
&lt;ol>
&lt;li>Earth&lt;/li>
&lt;li>Stone&lt;/li>
&lt;li>Puddle&lt;/li>
&lt;li>Grass&lt;/li>
&lt;/ol>
&lt;p>&lt;img alt="alt text" src="https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/f-25-dad-424-sound-design-for-games/lectures/week-9/attaching-audio-to-animations/material-sheet.png">&lt;/p>
&lt;p>Set the parameter to Hold during playback to allow the current footstep to complete even if the player moves to a different surface.&lt;/p>
&lt;p>&lt;img alt="alt text" src="https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/f-25-dad-424-sound-design-for-games/lectures/week-9/attaching-audio-to-animations/set-to-hold.png">&lt;/p>
&lt;p>Add a Multi Instrument (right-click, then &lt;code>Add Multi Instrument&lt;/code>) for each material value and add the appropriate footstep samples for that surface. Enable Shuffle in the Multi Instrument settings to randomize footstep playback.&lt;/p>
&lt;p>&lt;img alt="alt text" src="https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/f-25-dad-424-sound-design-for-games/lectures/week-9/attaching-audio-to-animations/mutli-instrument.png">&lt;/p>
&lt;p>Now, when you select different values for the &lt;code>Material&lt;/code> parameter, you’ll hear footsteps on different surfaces.&lt;/p>
&lt;p>Save your project and build your banks before switching back to Unity.&lt;/p>
&lt;hr>
&lt;h2 id="unity-project-setup">Unity Project Setup&lt;/h2>
&lt;p>Create a script named &lt;code>F_Player&lt;/code> and add it to your player (Ellen) GameObject. This script will own all player-related SFX behaviors.&lt;/p>
&lt;h3 id="the-reusable-one-shot-function">The Reusable One-Shot Function&lt;/h3>
&lt;p>We’ll implement a “play one-shot with control” pattern: create an instance, attach it to the player, start it, and release it—while still allowing parameter control if we need it later.&lt;/p>
&lt;p>Here’s a simple implementation using a new &lt;code>PlayRunEvent&lt;/code> function. We use a public function so that Unity Animation Events can call it directly. For now we hardcode the event path; in the next section we’ll update the function to accept a string parameter so different animations can play different events.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-csharp" data-lang="csharp">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">public&lt;/span> &lt;span style="color:#66d9ef">void&lt;/span> PlayRunEvent()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> EventInstance run = RuntimeManager.CreateInstance(&lt;span style="color:#e6db74">&amp;#34;event:/SFX/Ellen/Ellen_Run&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RuntimeManager.AttachInstanceToGameObject(run, gameObject, GetComponent&amp;lt;Rigidbody&amp;gt;());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> run.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> run.release();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Why this approach instead of &lt;code>RuntimeManager.PlayOneShot(...)&lt;/code>?&lt;/p>
&lt;ul>
&lt;li>It gives you full control over parameters (e.g., &lt;code>Material&lt;/code>) per trigger.&lt;/li>
&lt;li>It’s easy to reuse: different animations can pass different event paths into the same function.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="hooking-up-unity-animation-events">Hooking Up Unity Animation Events&lt;/h2>
&lt;p>Animation Events in Unity let an animation call your function at a specific frame. For footsteps, add an event exactly when each foot contacts the ground.&lt;/p>
&lt;ol>
&lt;li>Locate Ellen’s run animations in the Project window:
&lt;ul>
&lt;li>&lt;code>3DGameKit/Art/Animations/AnimationClips/Characters/Ellen/&lt;/code>&lt;/li>
&lt;li>Expand the &lt;code>Ellen Run Forward&lt;/code> FBX to see its clips (forward, diagonal, etc.).&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Preview the clip in the Inspector. If you see “No model is available for preview,” drag the Ellen model into the preview window from &lt;code>Art/Models/Characters/Ellen&lt;/code>.&lt;/li>
&lt;li>Find the &lt;code>Ellen_Run_Forward&lt;/code> clip and click it to open the Animation tab. Click Edit to unlock it for modification.
&lt;ol>
&lt;li>&lt;img alt="alt text" src="https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/f-25-dad-424-sound-design-for-games/lectures/week-9/attaching-audio-to-animations/ellen-animation.png">&lt;/li>
&lt;/ol>
&lt;/li>
&lt;li>Open the Events tab on the animation.
&lt;ol>
&lt;li>&lt;img alt="alt text" src="https://dsu-digital-sound-design.github.io/f-25-dad-424-sound-design-for-games/f-25-dad-424-sound-design-for-games/lectures/week-9/attaching-audio-to-animations/events.png">&lt;/li>
&lt;/ol>
&lt;/li>
&lt;li>Scrub the timeline to the exact frame the foot contacts the ground.&lt;/li>
&lt;li>Click Add Event. In the Function field, enter &lt;code>PlayRunEvent&lt;/code>.&lt;/li>
&lt;li>Add a second event for the other foot.&lt;/li>
&lt;li>Click Apply to save the clip modifications.&lt;/li>
&lt;li>Play the scene and run forward; you should hear a footstep on each contact.&lt;/li>
&lt;/ol>
&lt;p>Important: The script containing the target function must live on the same GameObject that plays the animation via an Animator. Otherwise, the Animation Event won’t be able to find your function.&lt;/p>
&lt;hr>
&lt;h2 id="add-the-event-path-parameter">Add the Event Path Parameter&lt;/h2>
&lt;p>Now that the events are triggering, let’s pass the FMOD event path as a string parameter so we can reuse this function for other animations (like landing or attacking) later.&lt;/p>
&lt;p>Edit your &lt;code>F_Player&lt;/code> script to update &lt;code>PlayRunEvent&lt;/code> to accept a string parameter for the event path, as shown below.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-csharp" data-lang="csharp">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">public&lt;/span> &lt;span style="color:#66d9ef">void&lt;/span> PlayRunEvent(&lt;span style="color:#66d9ef">string&lt;/span> eventPath)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> EventInstance run = RuntimeManager.CreateInstance(eventPath);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RuntimeManager.AttachInstanceToGameObject(run, gameObject, GetComponent&amp;lt;Rigidbody&amp;gt;());
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> run.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> run.release();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In your Animation Events, update each event to pass the event path string:
&lt;code>event:/SFX/Ellen/Ellen_Run&lt;/code> (or whatever your event path is).&lt;/p>
&lt;hr>
&lt;h2 id="understanding-c-parameters">Understanding C# Parameters&lt;/h2>
&lt;p>We defined &lt;code>PlayRunEvent(string eventPath)&lt;/code> so each animation can pass its own FMOD event path. This is a value parameter: the Animation Event provides a string, Unity passes it into your function at call time, and you use that to create the event instance.&lt;/p>
&lt;p>This pattern scales nicely:&lt;/p>
&lt;ul>
&lt;li>Walk clip → &lt;code>event:/SFX/Ellen/Ellen_Walk&lt;/code>&lt;/li>
&lt;li>Land clip → &lt;code>event:/SFX/Ellen/Ellen_Land&lt;/code>&lt;/li>
&lt;li>Attack clip → &lt;code>event:/SFX/Ellen/Ellen_Slash&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>You keep one function and let animations decide which event to play.&lt;/p>
&lt;hr>
&lt;h2 id="common-pitfalls">Common Pitfalls&lt;/h2>
&lt;ul>
&lt;li>The function name in Animation Events must match exactly, including case.&lt;/li>
&lt;li>The script with &lt;code>PlayRunEvent&lt;/code> must be on the animated GameObject (the same one with the Animator).&lt;/li>
&lt;li>Don’t forget to click Apply after editing Animation Events; missed applies are a classic time sink.&lt;/li>
&lt;li>Always call &lt;code>release()&lt;/code> after &lt;code>start()&lt;/code>; this defers cleanup until playback ends.&lt;/li>
&lt;li>If your footstep feels off by a few frames, adjust the event position slightly in the animation timeline—what looks like “contact” in the mesh may need a tiny lead or lag to feel right in-game.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="helpful-links">Helpful Links&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://docs.unity3d.com/Manual/AnimationEvents.html">Unity Animation Events Documentation&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://fmod.com/resources/documentation-unity?version=2.0&amp;page=welcome.html">FMOD Unity Integration Documentation&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://fmod.com/resources/documentation-api?version=2.0&amp;page=core-api-studio-eventinstance.html">FMOD EventInstance API Reference&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://docs.unity3d.com/ScriptReference/Rigidbody.html">Unity Scripting API: Rigidbody&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="more-complete-version-with-error-checking-and-parameterization">More complete version with error checking and parameterization:&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-csharp" data-lang="csharp">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">using&lt;/span> UnityEngine;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">using&lt;/span> FMODUnity; &lt;span style="color:#75715e">// FMOD Unity integration&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">using&lt;/span> FMOD.Studio; &lt;span style="color:#75715e">// FMOD Studio API&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">// by including these namespaces, we can use FMOD types directly&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">public&lt;/span> &lt;span style="color:#66d9ef">class&lt;/span> &lt;span style="color:#a6e22e">F_Player&lt;/span> : MonoBehaviour
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>{
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">// Optional: cache components you’ll likely need&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">private&lt;/span> Rigidbody _rb;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">void&lt;/span> Awake()
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> _rb = GetComponent&amp;lt;Rigidbody&amp;gt;();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">// Called by Unity Animation Events. Pass an FMOD event path, e.g. &amp;#34;event:/SFX/Ellen/Ellen_Run&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">public&lt;/span> &lt;span style="color:#66d9ef">void&lt;/span> PlayRunEvent(&lt;span style="color:#66d9ef">string&lt;/span> eventPath)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">if&lt;/span> (&lt;span style="color:#66d9ef">string&lt;/span>.IsNullOrEmpty(eventPath))
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Debug.LogWarning(&lt;span style="color:#e6db74">&amp;#34;PlayRunEvent called without a valid FMOD event path.&amp;#34;&lt;/span>);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#66d9ef">return&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> EventInstance run = RuntimeManager.CreateInstance(eventPath);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75715e">// Attach to this GameObject so the sound follows the player and 3D attenuation works as expected&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> RuntimeManager.AttachInstanceToGameObject(run, gameObject, _rb);
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> run.start();
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> run.release(); &lt;span style="color:#75715e">// Safe: schedules the instance for cleanup after playback finishes&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></content></item></channel></rss>