Can code from Unity communicate general game state to FMOD? Have I got FMOD totally wrong?

Hi,
New to FMOD and new to Unity.
My profession is in Audio and composition.

Before I even begin, I want to say that I have done hours and hours of research on youtube and on the FMOD site but because of my “extreme” gap of knowledge within coding and basic software dev for games, I really feel I need someones guidance on this, as it’s difficult for me to answer.

So, the question is from my programmer:

Can I communicate general game state to FMOD?

  • that is, not associated with any particular event (like a tower shooting).

Example game state:
isInGameplay: true
currentMap: Volcano Lair
numberOfWaypointsRemaining: 20 percent
numberOfEnemiesAlive: 43
numberOfMobEnemiesAlive: 36
numberOfRobotEnemiesAlive: 7

Then, can you use this information as the FMOD user without being associated with any particular event?

An example of what I mean is:
Play the menu / gameplay track
Increase music intensity because there’s only one waypoint left
Add and intensify a mob ambience based on the number of “mob enemies” (e.g. humans, brutes) alive
Add and intensify a different ambience based on the number of “robot enemies” (e.g. tank bots, bomb bots) alive
Whatever else you like, ideally without even having to leave FMOD?

  • Basically, I think my programmer is just wanting to know how much he does and doesn’t need to do.
    He’s trying to find the most efficient way to code the game, obviously, the less code he does and the more I can manipulate, the better.
    He’s just struggling to know what FMOD can really do and what infomation it can actually use from code source.

Thankyou, Rob

This is a complex question, and its answer is somewhere between yes and no.

You can communicate your game’s state to FMOD in ways that aren’t associated with particular events. The tool for doing so is “global parameters.” Each global parameter is a variable defined as part of your FMOD Studio project. Unlike local parameters, global parameters exist outside of your project’s events, though they can be read and used by any event in your project.

However, FMOD Studio is not designed to replace the function of your game’s engine, so it doesn’t support complex logic outside the context of events. As such, if you want the FMOD engine to respond to your setting a global parameter in any way, it can only do from within an event.

I’ll address each of your examples.

Playing music requires creating and playing an event instance. The usual way to create and play event instances is do so in your game’s code, but you could also do it by triggering an event instrument or start event command instrument in an already-playing event instance.

The standard way to do this would be to have a “waypoints left” parameter that your game’s code sets whenever the relevant game state changes, and for your music events to have behavior that depends on the value of that parameter.

There’s a few different ways you could do this, but assuming you want there to be a single ongoing ambience event that changes in intensity depending on the number of creatures of a particular kind present, you’d create a “number of robots” (or “number of mobs”) parameter, have your game’s code set that parameter whenever the relevant game state changes, and ensure the “robot ambiance” (or “mob ambiance”) event contains content that behaves differently depending on the value of that parameter.

I hope that answers your question.

This is an excellent response. Thankyou