0
0

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#):
[code:2msp2mj7]
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");
}

}
[/code:2msp2mj7]

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

  • You must to post comments
0
0

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!

  • You must to post comments
0
0

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

[code:2jq3503a]

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

  print("bounce");

}
[/code:2jq3503a]

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

  • You must to post comments
0
0

[quote:3bhorrdo]Does anyone know if there are any performance issues with geting & releasing events all the time….?[/quote:3bhorrdo]
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.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.