Game Development Community

Press a key for Auto Run???

by Eric Clausing · in Torque Game Engine · 02/12/2007 (4:33 pm) · 8 replies

Is there a way for a user to just assign a key and have it auto run forward? Like num lock back in the EQ days.

#1
02/13/2007 (6:26 am)
This is probably better suited for the public forums, since the solution is a script example, but here ya go:

In example\starter.fps\client\scripts\default.bind.cs:
$bAutoRun = 0;
function toggleAutoRun(%val)
{
   if(%val)
   {
      $bAutoRun = !$bAutoRun;
      $mvForwardAction = $bAutoRun * $movementSpeed;
   }
}
moveMap.bind( keyboard, scrolllock, toggleAutoRun);
#2
02/13/2007 (7:01 am)
.
#3
02/13/2007 (7:05 am)
I tested the code, and it works fine. No errors, and functionality is perfectly replicated.
#4
02/13/2007 (7:11 am)
.
#5
02/13/2007 (7:13 am)
The one amendment I'll make to the code is this:

function moveforward(%val)
{
   $mvForwardAction = %val * $movementSpeed;
  [b] $bAutoRun = 0;[/b]
}

This will reset auto running once the player takes control again, much like EQ, DAoC and so on.

*EDIT* You'll obviously want to repeat this in moveBackward.
#6
02/13/2007 (9:11 am)
.
#7
02/13/2007 (9:36 am)
Sweet. That got me going. Thanks Michael.
#8
02/13/2007 (9:51 am)
Happy to help out Eric