Game Development Community

Keyboard Input

by praju · in Torque Game Builder · 09/17/2010 (9:54 am) · 0 replies

Hi guys,

I am having a little trouble while moving a player with the keyboard input.

This is the code for left turn.

if($player.moveLeft)
{
$player.setRotation($player.getRotation()-3);
}

There is an updateMovementFunction which checks for keypress using the above condition. This function is executed every frame.

If i was pressing left turn for my player, it turns left. But the problem is that, if suddenly the controlling player is switched, the new player keeps turning in left circles without even the key press - goes out of control. I think the current rotation value is added to the new controlling player.

Can you guys please give some suggestions to rectify this????

Thanks in advance!!!