# Predefined positioning/Setting up 2d Pathing (Front, Back, Left and Right) in FMOD bullet whiz-by event

Good evening all

I am trying to figure out how to creat audio paths in FMOD studio 1.10.11 for a multi-instrument event for bullet whiz-by’s. there’s documentation for it for Wwise, but not for FMOD, however folks at GDC last weekend were saying it could be a parameter setup question. And that the calculation for it was a Dot Product formula.

here is the concept I’ve been given:

The idea is that you would create four paths (left->right, right->left, front->back, back->front) and choose which one to play based on the relative direction of the listener forward and the bullet direction. To pick a direction:

let:

f = normalized listener forward vector

d = normalized bullet direction vector

u = normalized up vector

x = vector cross product operation

. = vector dot product operation

A = f . d -> front or back: > 0 means it is moving back to front, < 0 means front to back

B = (f x u) . d -> left or right: > 0 will be right->left and < 0 will be left->;right, or vice versa depending on whether you are left- or right-handed cartesian (just flip the sign if it sounds wrong)

Run both of these calculations, that will give you two floating point values. Take whichever one is largest, then look at its sign to determine the final result. Code would look something like this:

A = dot(f, d)

B = dot(cross(f, u), d)

if (abs(A) > abs(B))

``````if (A > 0) return FRONT else return BACK
``````

else

``````if (B > 0) return LEFT else return RIGHT
``````

Just not sure how to set this up in FMOD

Since you’ve already written your code, it sounds like you’d want to create an event with a labelled parameter whose values are “FRONT”, “BACK”, “LEFT”, and “RIGHT” (or “Front to back”, “Back to front”, “Left to right”, and “Right to left”, if you prefer). Under each of those values you’d put an instrument containing one or more audio files with baked-in panning appropriate to that parameter value. All you’d need to do then is set the value of the parameter after creating an instance of the event but before playing the instance.

But I haven’t written any code anywhere. The text just generated it as code. What I was writing was the concept another developer was emailing me

But I haven’t written any code anywhere. What I was writing was the concept another developer was emailing me.

The point still stands: You have a clear idea of what information you want your code to generate for FMOD Studio, and the way to set the behavior of an FMOD Studio event is to use a parameter. The solution I suggested includes a parameter that will accept the values you feed FMOD Studio and produce the four behaviors you requested depending on which value it receives.

Side note: The FMOD automation update isn’t fast enough for using envelopes for quick short pan sweeps, such as bullet whiz-bys. It will sound stuttery (I’ve tried). You may have to rely on pre-baked wav assets to get a smoother result. For slower pass-bys the internal FMOD automation is fine.

You can save memory and channels by just creating a left-right stereo sweep in your DAW, then using the Surround L/R panner to play it in front, rear, left or right, with the channels flipped for the opposite direction.