Sounds and gamepad?
by Bhood · in Hardware Issues · 12/19/2005 (3:18 am) · 1 replies
Hi there,
I'm setting up gamepad/joystick usability for my game but am having problems with sound. I've got footstep sounds set and working for the keyboard arrows moving forward and backwards but these don't work properly with the other controllers i.e. they play really fast and don't stop, which I understand is because it's constantly updating...
So, can anyone suggest a better way to set up my footstep sounds for the gamepad? I'm currently using the following code...
thanks, Bev
//--joystick move forward function from presetkeys.cs (equivalent to default.bind.cs)
function moveforward2(%val)
{
if( %val > - 0.7 && %val < 0.7 )
{
$mvForwardAction = 0;
return;
}
$mvForwardAction = -%val*$movementSpeed;
if (%val)
commandToServer('startFootsteps');
else
commandToServer('stopFootsteps');
}
//--referencing this part of my file called footsteps.cs...
datablock AudioProfile(Footstep1)
{
fileName = "~/data/sound/FootStep1.wav";
description = "AudioClosest3d";
preload = true;
};
function serverCmdStartFootsteps(%client)
{
%client.player.schedule(200,playFootstep);
%client.player.footstepson = true;
}
function serverCmdStopFootsteps(%client)
{
%client.player.footstepson = false;
}
function Player::playFootstep(%this)
{
if(%this.footstepson)
{
serverPlay3D(FootStep1,%this.getTransform());
%this.schedule(500,playFootstep);
}
}
I'm setting up gamepad/joystick usability for my game but am having problems with sound. I've got footstep sounds set and working for the keyboard arrows moving forward and backwards but these don't work properly with the other controllers i.e. they play really fast and don't stop, which I understand is because it's constantly updating...
So, can anyone suggest a better way to set up my footstep sounds for the gamepad? I'm currently using the following code...
thanks, Bev
//--joystick move forward function from presetkeys.cs (equivalent to default.bind.cs)
function moveforward2(%val)
{
if( %val > - 0.7 && %val < 0.7 )
{
$mvForwardAction = 0;
return;
}
$mvForwardAction = -%val*$movementSpeed;
if (%val)
commandToServer('startFootsteps');
else
commandToServer('stopFootsteps');
}
//--referencing this part of my file called footsteps.cs...
datablock AudioProfile(Footstep1)
{
fileName = "~/data/sound/FootStep1.wav";
description = "AudioClosest3d";
preload = true;
};
function serverCmdStartFootsteps(%client)
{
%client.player.schedule(200,playFootstep);
%client.player.footstepson = true;
}
function serverCmdStopFootsteps(%client)
{
%client.player.footstepson = false;
}
function Player::playFootstep(%this)
{
if(%this.footstepson)
{
serverPlay3D(FootStep1,%this.getTransform());
%this.schedule(500,playFootstep);
}
}
Associate Tom Spilman
Sickhead Games