Attached Instance Distance Calculation for 2D Game

Hello. I have a 2D game where we use the depth pretty liberally to get things to visually sort correctly. But this causes and issue when we used attached game objects to provide the position because it factors in the depth when doing the 3D distance calculation for fall off.

Is there a way for us to instruct FMOD to ignore the Z component of the distance when calculating the distance to the audio listener?

Hi,

There’s no simple Studio API or Unity integration function to instruct FMOD to ignore the Z axis. That said, by “attached game objects” I assume you mean using RuntimeManager.AttachInstanceToGameObject?

If this is the case, and you don’t require the Z axis for any attached instances, the simplest way to do what you want would be to modify RuntimeUtils.To3DAttributes and its overloads to strip the Z component from transform and velocity. RuntimeManager relies on these methods to update the 3D attributes of attached event instances, which you can see between lines 467 and 498 of RuntimeManager.cs.

Thanks, Louis! That’s exactly what I meant and I foolishly didn’t even think through forking the plugin and making local modifications. Ha ha. Thanks!

1 Like