what is the meaning by ((%this.right - %this.left) * %this.horizontalSpeed);
by jack518 · in Torque Game Builder · 09/02/2009 (10:49 pm) · 2 replies
Hi, I am working on Rainy Day tutorial, but some lines of codes shown next confuse me much.
function MovementBehavior::updateMovement(%this)
{
// make the player move
%this.owner.setLinearVelocityX((%this.right - %this.left) * %this.horizontalSpeed);
%this.owner.setLinearVelocityY((%this.down - %this.up) * %this.verticalSpeed);
}
function MovementBehavior::updateMovement(%this)
{
// make the player move
%this.owner.setLinearVelocityX((%this.right - %this.left) * %this.horizontalSpeed);
%this.owner.setLinearVelocityY((%this.down - %this.up) * %this.verticalSpeed);
}
Associate Phillip O'Shea
Violent Tulip
- If Left is held down, then X-Axis velocity will be ( 0 - 1 ) * Speed.
- If Right is held down, then X-Axis velocity will be ( 1 - 0 ) * Speed.
- If both Left & Right are held down, the X-Axis velocity will be ( 1 - 1 ) * Speed.
Do the same for Up/Down and you should get the idea.