I need play a sound panning depend on X coord of explosion.
Vector2 PositionOfExplosion = ExplosionCoord;
myScreenWidth = 480; //Windows phone
float SoundPan = ??? //Mus be something like MathHelper.Clamp(???, -1, 1);
_explosion1.Play(myVolumen, myPitch, SoundPan); // Pan from -1.0 left to 1.0 right. 0 is center
Resuming,
If explosion is in
X=0 Pan= -1
...
X=120 Pan= -0.5
...
X=240 Pan= 0
...
x=360 Pan = 0.5
...
x=480 Pan= 1
Sorry my english.
Thanks.
pan = (PositionOfExplosion.X - 240.0f) / 240.0fYou can then clamp to
-1..1.