2 buttons pressed = 0
by rennie moffat · in Torque Game Builder · 11/10/2009 (6:33 pm) · 2 replies
Hi, I have set up the condition so that when I press (in this case (down + (left or right)) && (up && (left or right)) that all LINEAR movement is canceld. IMPORTANT: my player only travels X or Y, no diagnols. I set up the correct if statments and it works however I have 2 questions from it.
When both buttons are pressed at the same time [italics](or as in most cases)[/italics] nano seconds apart due to human error, my player appears to make a slight diagonal jump before stopping. So my question is, is there any way to create a "buffer" between button presses so that this does not occur & is there a simpler way to code what I have coded.
Thanks,
Ren
When both buttons are pressed at the same time [italics](or as in most cases)[/italics] nano seconds apart due to human error, my player appears to make a slight diagonal jump before stopping. So my question is, is there any way to create a "buffer" between button presses so that this does not occur & is there a simpler way to code what I have coded.
Thanks,
Ren
function Spacer3000Controls::onUpdate(%this)
{
%this.owner.setLinearVelocityY((%this.down - %this.up) * %this.YSpeed);
%this.owner.setLinearVelocityX((%this.right - %this.left) * %this.XSpeed);
if(%this.up && %this.left)
{
%this.up = 0;
%this.left = 0;
}
if(%this.up && %this.right)
{
%this.up = 0;
%this.right = 0;
}
if(%this.down && %this.right)
{
%this.down = 0;
%this.right = 0;
}
if(%this.down && %this.left)
{
%this.down = 0;
%this.left = 0;
}
}About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
So I think in theory I want to give the illusion that the player only moves up, or down, nothing else. So you are suggesting to use a getPosition and if moving along X, Y stays constant?
11/11/2009 (11:58 am)
Hmm. So I think in theory I want to give the illusion that the player only moves up, or down, nothing else. So you are suggesting to use a getPosition and if moving along X, Y stays constant?
Milan Rancic
If that is not enough, since player is always moving by X and Y axis, you can remember his X and Y position and keep it always at those values "by force".