# One Shot Events with automation parameters

**URL:** <https://qa.fmod.com/t/one-shot-events-with-automation-parameters/11336>\
**Category:** Unity\
**Created:** [March 14, 2014, 2:43pm UTC](https://qa.fmod.com/t/one-shot-events-with-automation-parameters/11336 "2014-03-14T14:43:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreasfr](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@andreasfr](https://qa.fmod.com/u/andreasfr)\
**Post date:** [March 14, 2014, 2:43pm UTC](https://qa.fmod.com/t/one-shot-events-with-automation-parameters/11336/1 "2014-03-14T14:43:37Z")

</div>

Hello FMOD

I’m trying to start events as one shots and also control automation parameters.  
From what you wrote on another topic it looks like I should get the event-instance, start and then release the instance.

I have a ball that bounces and I want the impact sound to play each time the ball hits the floor.

I wrote this (C#):

```auto
using UnityEngine;
using System.Collections;
using FMOD.Studio;

public class sphereTrigger : MonoBehaviour 
{
	FMOD.Studio.EventInstance oneShot;
	
	void Start () 
	{
		oneShot = FMOD_StudioSystem.instance.getEvent("event:/oneShot");
	}

	void OnCollisionEnter() 
	{
		oneShot.start();
		oneShot.release();

		print("bounce");
	}
}
```

Console is printing “bounce” each time the ball hits the floor, BUT the sound is only played the first time!

The event contains one event sound with default settings. Everything sounds as it should except the sound is only played once.

What am I missing?

Cheers,  
Andreas

---

<div class="post-metadata">

**Author:** ![yeashop](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/yeashop/32/3626_2.png) [@yeashop](https://qa.fmod.com/u/yeashop)\
**Post date:** [June 7, 2014, 7:19pm UTC](https://qa.fmod.com/t/one-shot-events-with-automation-parameters/11336/2 "2014-06-07T19:19:42Z")

</div>

Hi Peter,

I’m having trouble with this script for launching 3D oneshot sounds. It works fine with 2D sounds but can’t launch 3D sounds. I’m having trouble finding any documentation on scripting 3D sounds using FMOD in Unity. Is there anyway you could give a few pointers? If anyone else has some tips for this please let me know!

---

<div class="post-metadata">

**Author:** ![atomtwist](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@atomtwist](https://qa.fmod.com/u/atomtwist)\
**Post date:** [March 14, 2014, 4:40pm UTC](https://qa.fmod.com/t/one-shot-events-with-automation-parameters/11336/3 "2014-03-14T16:40:09Z")

</div>

Try to use getEvent everytime before you start the the event,  
because once you release the event, the EventInstance is empty.

```auto

void OnCollisionEnter() 
   {
      oneShot = FMOD_StudioSystem.instance.getEvent("event:/oneShot");
      oneShot.start();
      oneShot.release();

      print("bounce");
   }
```

Does anyone know if there are any performance issues with geting & releasing events all the time…?

---

<div class="post-metadata">

**Author:** ![Guest1](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Guest1](https://qa.fmod.com/u/Guest1)\
**Post date:** [March 17, 2014, 3:03am UTC](https://qa.fmod.com/t/one-shot-events-with-automation-parameters/11336/4 "2014-03-17T03:03:17Z")

</div>

> [@](#):
>
> Does anyone know if there are any performance issues with geting & releasing events all the time…?

No there shouldn’t be any performance issues, that is the recommended method for firing off oneshot events. The release will make sure all the resources for the instance are cleaned up when the event finishes.
