[bug] TGB does not recognize more than two buttons
by Aleksandar Sandic · in Torque Game Builder · 10/22/2010 (10:18 am) · 0 replies
Here is the deal:
I am writing the controls behaviour for a platformer, where the player can duck, run and jump all at the same time. the buttons were mapped as following:
-left/right for running
-up for jumping
-down for ducking
the problem:
only two buttons could be registered at the same time. I put echo() functions right at the very beginning, so even if pressing or releasing a button does nothing in the game, it gives at least an echo. But in my case I could only duck and jump or duck and run, not jump while running in a ducking state. There was no echo either, so the button was not read.
This is not limited to the arrow keys. I tried the same thing using WASD, same results.
the solution (kind of):
When I spread the keys apart, everything works. In my case, I simply used ASD for walking/ducking an up for jumping -> everything works as expected.
my assumption:
TGB seems to have a problem, when the keys are near another. For a platformer, I can simply spread them across the keyboard, but what about a Street Fighter kind of game which uses quite a lot of buttons?
I have written a small behaviour so everyone can quickly experiment around a bit. Just attach it to anything and try outdifferent button mappings
EDIT:
My operating system is Mac OS X 10.6.4 using the aluminium Apple keyboard with cord, running TGB 1.7.5
I am writing the controls behaviour for a platformer, where the player can duck, run and jump all at the same time. the buttons were mapped as following:
-left/right for running
-up for jumping
-down for ducking
the problem:
only two buttons could be registered at the same time. I put echo() functions right at the very beginning, so even if pressing or releasing a button does nothing in the game, it gives at least an echo. But in my case I could only duck and jump or duck and run, not jump while running in a ducking state. There was no echo either, so the button was not read.
This is not limited to the arrow keys. I tried the same thing using WASD, same results.
the solution (kind of):
When I spread the keys apart, everything works. In my case, I simply used ASD for walking/ducking an up for jumping -> everything works as expected.
my assumption:
TGB seems to have a problem, when the keys are near another. For a platformer, I can simply spread them across the keyboard, but what about a Street Fighter kind of game which uses quite a lot of buttons?
I have written a small behaviour so everyone can quickly experiment around a bit. Just attach it to anything and try outdifferent button mappings
if(!isObject(keyTestBehavior))
{
%template = new BehaviorTemplate(keyTestBehavior);
%template.friendlyName = "keyTestBehavior";
%template.behaviorType = "Input";
%template.description = "tests how many jkeys can be pressed simultaneously";
%template.addBehaviorField(key1, "first key", keybind, "A");
%template.addBehaviorField(key2, "second key", keybind, "S");
%template.addBehaviorField(key3, "third key", keybind, "D");
%template.addBehaviorField(key4, "fouth key", keybind, "F");
%template.addBehaviorField(key5, "fith key", keybind, "G");
}
function keyTestBehavior::onBehaviorAdd(%this){
if(!isObject(moveMap))
return;
moveMap.bindObj(getWord(%this.key1, 0), getWord(%this.key1, 1), "lol", %this);
moveMap.bindObj(getWord(%this.key2, 0), getWord(%this.key2, 1), "rofl", %this);
moveMap.bindObj(getWord(%this.key3, 0), getWord(%this.key3, 1), "pwned", %this);
moveMap.bindObj(getWord(%this.key4, 0), getWord(%this.key4, 1), "omg", %this);
moveMap.bindObj(getWord(%this.key5, 0), getWord(%this.key5, 1), "wtf", %this);
}
function keyTestBehavior::onBehaviorRemove(%this){
if(!isObject(moveMap))
return;
moveMap.unbindObj(getWord(%this.key1, 0), getWord(%this.key1, 1), %this);
moveMap.unbindObj(getWord(%this.key2, 0), getWord(%this.key2, 1), %this);
moveMap.unbindObj(getWord(%this.key3, 0), getWord(%this.key3, 1), %this);
moveMap.unbindObj(getWord(%this.key4, 0), getWord(%this.key4, 1), %this);
moveMap.unbindObj(getWord(%this.key5, 0), getWord(%this.key5, 1), %this);
}
function keyTestBehavior:: lol(%this, %val){
echo("key 1 pressed?" SPC %val);
}
function keyTestBehavior:: rofl(%this, %val){
echo("key 2 pressed?" SPC %val);
}
function keyTestBehavior:: pwned(%this, %val){
echo("key 3 pressed?" SPC %val);
}
function keyTestBehavior:: omg(%this, %val){
echo("key 4 pressed?" SPC %val);
}
function keyTestBehavior:: wtf(%this, %val){
echo("key 5 pressed?" SPC %val);
}please excuse the stupid names of the functions; I had them all systematically numbered, but TGB didn't like functions starting with numbers, so I quickly replaced them with something stupid.EDIT:
My operating system is Mac OS X 10.6.4 using the aluminium Apple keyboard with cord, running TGB 1.7.5