As Alan .V. Drake stated in the AGS 3.3 wishlist the functionality of the panning footstep sounds depends where you are on the screen. So for example far left (x = 0) would be panned to -100 and then get to 640 it would a full 100 pan.
The game is at 640x400 so I need to figure out the equation to do this. But for the life of me I can't figure out. I know I can use channel.panning function and to put this functionality in repeatedly_execute_always(). Any ideas?
its called normalisation.
panning = (x / 3.2) - 100;
You can get around the equation part of it by looking at it logically: Dead center (x = 320) panning would be 0, obviously, and since the values in question are between 0 and 100 each direction, you can work it out like a percentage. 100/320 = 0.3125 so to get the correct pan depending on x location it would be:
pan = -100 + (0.3125 x player.x)
So say the player is at x position 200 (so slightly to the left of the center), the equation would be -100 + (0.3125 x 200) = -37.5
Hope this helps!
Edit: Damn beat me to it!
I thought that was the equation Calin. I just wanted to make sure :) Thanks for the confirmation
although you may want to avoid hard pans.. even if the character is on the left side of the screen that doesnt equate to a full left pan.
Subtley is key with shit like that.
What do you suggest Calin?
EDIT: I tried applying that equation to coding, but I cant seem to compile. I figured you would need a float variable of some description. But for example this doesn't work.
float PanFoot = (cEgo.x / 3.2) - 100;
try this
int PanFoot = (cEgo.x / 6) - 50
That would give you a pan of about -50 to +50
You should go with what Calin said, but just to explain why yours did not compile, it's because you mixed floats and ints, you should have done:
float PanFoot = (IntToFloat(cEgo.x) / 3.2) - 100.0;
yea tzachs is 100% right.
The reason I elected NOT to use floats was simply because that level of accuracy wasnt needed and it would look messy and have functions and brackets all over the place.
This is a sketchy code I use to calculate the panning position (adjusted to 640)
int PanningPosition(int x){
int panning = ((x-(320+GetViewportX()))*10)/32; //...because I hate floats
if (panning > 100) panning = 100; // In the case the character is off the viewport
if (panning < -100) panning = -100; //--
return panning;
}
Quote from: Alan v.Drake on Thu 29/04/2010 18:51:33
This is a sketchy code I use to calculate the panning position (adjusted to 640)
int PanningPosition(int x){
int panning = ((x-(320+GetViewportX()))*10)/32; //...because I hate floats
if (panning > 100) panning = 100; // In the case the character is off the viewport
if (panning < -100) panning = -100; //--
return panning;
}
Hi Alan,
But how do you integrate the panning with the associate sound effect without actually have to play it initially?
Don't you have to have like
Footstepsound = aFootstep.Play();
Footstepsound.Panning = PanningPosition;
Either you play them manually or you'll need to make a script that scans the audio channels to see which one is playing footsteps and then checking how many characters are walking and do a little magic, in theory it should work, but I haven't tried it yet.
That's why it would be better if ags did this by itself.
EDIT: Check here for a pratical approach. (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36284.msg538902#msg538902)