Beginner in need of help
by Henry Trujillo · in Technical Issues · 05/13/2006 (4:15 pm) · 4 replies
Hi I am currently trying to modify the racing demo included with the torque engine and I am trying to play a sound when a button is pressed but I can quite figure it out. I can get the sound to play when the button is pressed but unfortunately the sound plays when I press the key as well as when I let go of the key. I have the sound play in the key bind script like this:
function handbrake(%val)
{
$mvTriggerCount2++;
alxPlay(ScoutSquealSound);
}
Im pretty sure this is what's causing the problem but I don't know how to fix it.
function handbrake(%val)
{
$mvTriggerCount2++;
alxPlay(ScoutSquealSound);
}
Im pretty sure this is what's causing the problem but I don't know how to fix it.
#2
if (%val=1)
{
alxPlay(ScoutSquealSound);
}
then like this:
if handbrake(%val=1)
{
alxPlay(ScoutSquealSound);
}
(handbrake is the name of the function by the way)
and then like this
if handbrake(%val=1)
{
alxPlay(ScoutSquealSound);
}
else
All of them gave me still give me the same problem. Is there something Im missing? Could it be that I also put this if statement in the handbrake function.
05/14/2006 (1:20 am)
Okay I tried it a couple of different ways first like this:if (%val=1)
{
alxPlay(ScoutSquealSound);
}
then like this:
if handbrake(%val=1)
{
alxPlay(ScoutSquealSound);
}
(handbrake is the name of the function by the way)
and then like this
if handbrake(%val=1)
{
alxPlay(ScoutSquealSound);
}
else
All of them gave me still give me the same problem. Is there something Im missing? Could it be that I also put this if statement in the handbrake function.
#3
Try this.
05/14/2006 (12:27 pm)
This snipplet won't workif handbrake(%val=1) <-- "=" is an assignment operator "==" compares to equal.
{
alxPlay(ScoutSquealSound);
}Try this.
function handbrake(%val)
{
if(%val)
{
$mvTriggerCount2++;
alxPlay(ScoutSquealSound);
}
}
#4
05/14/2006 (5:08 pm)
Tried your way Dave, and it works fine. Thank you so much. You have no idea how long I have been trying to fix this. You rock!
Torque 3D Owner Sean H.
if(%val)
before the code. functions that are binded to buttons get called twice, once when the button is first pressed (%val=1), and again when the button is released (%val=0).