# Replace Event While Playing

**URL:** https://qa.fmod.com/t/replace-event-while-playing/20865
**Category:** Unity
**Created:** [November 11, 2023, 9:50am UTC](https://qa.fmod.com/t/replace-event-while-playing/20865 "2023-11-11T09:50:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![littlenorwegians](https://avatars.discourse-cdn.com/v4/letter/l/ba8739/32.png) [@littlenorwegians](https://qa.fmod.com/u/littlenorwegians)
#### Post date: [November 11, 2023, 9:50am UTC](https://qa.fmod.com/t/replace-event-while-playing/20865/1 "2023-11-11T09:50:39Z")

</div>

Bit new to FMOD and I have a basic question. I have an established event emitter called “FootstepPlayer”. It has an event, “DefaultFootstep”, that plays when a character walks.

I have set up a trigger where I want to replace the event inside the eventemitter to “MetalFootstep”, but so far no luck.

```
public StudioEventEmitter FootstepPlayer;
public EventReference MetalFootstep;

public void OnTriggerEnter(Collider other){
FootstepPlayer.Event = MetalFootstep;

```

}

^Something along those lines. How do I do this?

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [November 13, 2023, 2:06am UTC](https://qa.fmod.com/t/replace-event-while-playing/20865/2 "2023-11-13T02:06:38Z")

</div>

StudioEventEmitter is designed to only handle a single event - as a result, if you don’t want to handle the lifetime of the event instance yourself, what you want will require you to make some sort of modification to the script.

As a basic example, the following function can be added to StudioEventEmitter, and will stop the currently playing instance and set the emitter to play your event of choice:

```auto
public void ChangeEvent(EventReference eventRef)
{
    Stop();
    EventReference = eventRef;
    Lookup();
}

```

You then do the following in your own script to set the emitter to use the MetalFootstep event when it enters the trigger:

```auto
public void OnTriggerEnter(Collider other)
{
    FootstepPlayer.ChangeEvent(MetalFootstep);
}

```
