Game Development Community

SetForwardSpeed - dosent work

by \"Robert Jaramillo\" · in Torque Game Builder · 02/19/2010 (11:11 am) · 1 replies

Hello, everyone

I don't know if you guys can help me or not but the function setforward speed dose not seem to work for me and I would really like to know why. Any suggestions would be helpful. Also I have pasted the code below that is using it.

function Harpoon::Fire(%this)
{
%this.bIsReadyToFire = false;
%this.setForwardSpeed(20);
}

The other question I had is can I use it in a this function as well but pass in a negative speed? to get it to return to the players center.

function Harpoon::Retract(%this, %points)
{
if(%this.getPosition() == $PlayerCenter)
{
$Player.InceraseScore(%points);
%this.bIsReadyToFire == true;
}
else
{
%this.Retract(%points);
%this.setForwardSpeed(20);
}
}

#1
02/19/2010 (12:44 pm)
setForwardSpeed() only works if setForwardMovementOnly() on the object is set to true.

If you remember back to physics class, there is no such thing as a negative speed. ;) So you can't put in a negative number with setForwardSpeed. All %this.setForwardSpeed(20); is doing is giving you an alternative way to write %this.setLinearVelocity(0, 20); . I don't really see any benefit to using setForwardSpeed over setLinearVelocity - and since you want to move an object in two different directions, then setLinearVelocity is what you should use.