Game Development Community

Moving a object back after using SetForwardSpeed

by \"Robert Jaramillo\" · in Torque Game Builder · 02/19/2010 (12:28 pm) · 7 replies

Hello, Everyone

I am curious if there is a way to move an object back using setFrowardspeed() function? If not, I could use your guy's help when it comes to figuring out how to do this. Below is the function that I am using. Please any help would be greatly appreciated.


function Harpoon::Retract(%this, %points)
{
if(%this.getPosition() == $PlayerCenter)
{
$Player.InceraseScore(%points);
%this.bIsReadyToFIre = true;
return;
}
else
{
//check if we have been in this function before
if(%this.getForwardMovementOnly() == true)
{
%this.SetForwardMovementOnly(false);
%this.setForwardSpeed(-20);

}
//%this.schedule(17, "Retract", %points);

}
return;
}

#1
02/19/2010 (12:50 pm)
I sort of answered this in your other thread about setForwardSpeed.

If you want to move an object along the Y axis for example, use setLinearVelocityY(20) and then to reverse it's direction and move it back use setLinearVelocityY(-20).
#2
02/19/2010 (2:29 pm)
will that work though based upon its rotation?
#3
02/19/2010 (2:55 pm)
will that work though based upon its rotation?
#4
02/19/2010 (3:15 pm)
will that work though based upon its rotation?
#5
02/19/2010 (3:21 pm)
will that work though based upon its rotation?
#6
02/19/2010 (4:09 pm)
No, no, no, and no.

Seriously, though, it's very poor form to post over and over. Some questions don't get answered for 24-72 hours after they are posted. I think it's reasonable to wait at least 24 before bumping your question up again and again.
#7
02/19/2010 (4:34 pm)
Robert, for rotation based movement, have a look at the setLinearVelocityPolar or setImpulseForcePolar functions.