Game Development Community

How can I check for "movement keys pressed" (w,a,s,d) ?

by University of Central FL (#0003) · in Torque Game Engine · 06/27/2006 (2:19 pm) · 5 replies

I'm trying to play one of 3 custom idle animations if the player hasn't pushed an action (trigger) or a move button.

I know I can access the trigger inputs from engine code using move->trigger[num], which are all booleans,
but I also need to check the movement keys (w,a,s,d for our game).

Does anyone know how to check these keys from engine code?

#1
06/27/2006 (6:30 pm)
The keys are mapped and processed in class ActionMap which is contained in ActionMap.cc. If you look at ActionMap::processAction() you'll see that the Node struct has a pointer to the console command located in default.bind.cs. You should be able to check the movement keys in either location. Hope this helps.
#2
06/27/2006 (7:27 pm)
Ok well I want to check for the movement keys in player.cc...is the player class able to see the actionMap? What would be the best way to check for these keys in the player class, or is this even possible?
#3
06/27/2006 (8:22 pm)
While monitoring the input may be the best way, it looks like it is possible to tie into the Player::processTick and keep track of the number of repeat times the 'move' is all zeros (the Move struct also contains the trigger info).
#4
06/27/2006 (8:57 pm)
Ok, I'm looking at the move struct in moveManager.h and here's the relevant variables:
// packed storage rep, set in clamp
   S32 px, py, pz;
   U32 pyaw, ppitch, proll;
   F32 x, y, z;          // float -1 to 1
   F32 yaw, pitch, roll; // 0-2PI
   U32 id;               // sync'd between server & client - debugging tool.
   U32 sendCount;

I assume x, y, and z are the ones I need to check. I remember seeing some posts about players being at rest though, and how the x,y, and z are really non-zero, but they are clamped to zero to make the player rest. So I should have to clamp these values to check for "no-input" as well, correct?
#5
06/27/2006 (10:19 pm)
Yes, it has been my experience too that they don't always report as true zero.