Game Development Community

Question on how jumping is dealt with in fps demo

by Dimitri Roche · in Torque Game Engine · 03/23/2005 (9:44 pm) · 1 replies

When in the Player.cc's updateMove() to decide whether player is jumping it does:
Quote:
// Acceleration from Jumping
if (move->trigger[2] && !isMounted() && canJump())
{
what is the move trigger? I've looked up the definitions and the referenced is in moveManager.h. I don't see how in the they associate trigger[2] with jump.

Where does the trigger[maxTriggerKeys] get defined and associated with movement in moveManager.h. it does some work with mTriggerCount in gameConnectionMoves.cc. I feel im right there yet im not.

like this:
Quote:
for(U32 i = 0; i < MaxTriggerKeys; i++)
{
curMove.trigger[i] = false;
if(MoveManager::mTriggerCount[i] & 1)
curMove.trigger[i] = true;
else if(!(MoveManager::mPrevTriggerCount[i] & 1) && MoveManager::mPrevTriggerCount[i] != MoveManager::mTriggerCount[i])
curMove.trigger[i] = true;
MoveManager::mPrevTriggerCount[i] = MoveManager::mTriggerCount[i];
}
curMove.clamp(); // clamp for net traffic

So what does the trigger array of size maxTriggerKeys ( = 6) hold and get associated with movement such as jump. Is it forward, backward, up, down, ???.

Sure I could map a key to another jump function unlike they have it in the demo, but I do wish to understand how they did it. I have to modify the jump extensively and add something similar and was hoping to do it in the same fashion instead of mapping keys to new functions.

Thanks.

#1
03/24/2005 (1:05 pm)
The triggers are general-purpose "buttom presses" you can pass in a move. They are generated dynamically based on MaxTriggerKeys. Stock Torque comes with 10 triggers, I think.

I take it you figured out Torque reads some global console variables to build a move, reading the current state of the forward, backwards and other movement values.

The Triggers (definied as console variables $mvTriggerCount0, $mvTriggerCount1, $mvTriggerCount2 etc) allow you to define "action buttoms" for your player. The demo app uses trigger[0] for primary fire, trigger[1] for alternative fire and trigger[2] for jump.

So, when you set $mvTriggerCount2 to 1, move->trigger[2] becomes 1.

The other triggers (3~9, I think) are funcitonal as well, and I advice you to use them if your player can perform other actions triggered by other buttoms, and you want the AiPlayers to be able to do the same.