ProcessTick
by Jonathan Shih · in Torque Game Engine · 07/30/2004 (5:03 pm) · 3 replies
I'm new to Torque and trying to figure out how object movement works, but I'm stuck at the processTick() function. I can't figure out where the 'Move' object that is passed in comes from. Can anyone help?
About the author
#2
More specifically, those 3 lines of code you mentioned are exactly where I am having trouble. My player is of the AIPlayer class, and I would like to use aiMove instead of the passed in move struct for player movements. For now, I am doing this quick fix until I understand where the passed in move struct comes from:
07/31/2004 (2:40 pm)
Sorry, my question wasn't quite clear. I was actually wondering where in the engine the move struct that is passed in is originally declared.More specifically, those 3 lines of code you mentioned are exactly where I am having trouble. My player is of the AIPlayer class, and I would like to use aiMove instead of the passed in move struct for player movements. For now, I am doing this quick fix until I understand where the passed in move struct comes from:
Move aiMove;
//if (!move && isServerObject() && getAIMove(&aiMove))
// move = &aiMove;
if (isServerObject() && getAIMove(&aiMove))
move = &aiMove;
#3
07/31/2004 (2:52 pm)
It's in the game/movemanager.h file. If you hope to start working with torque you'll definitely need an editor that can instantly navigate to declarations.
Torque Owner Andreas Papathanasis
processTick() is one of the three methods where you insert code for your object's state updates. The move struct is created and passed to this call by the engine. Move is not passed on every object. In fact, most objects will have this function called by the engine with move equal to NULL. Only objects that are controlled by a connection (e.g. the player in the FPS example) have the processTick() method called with a specific (non-NULL) move struct. This struct contains information gathered from user input on the client that controlls the object: for example, if the player has requested a move forward/backward, a jump, etc. So, you first check if the move structure is NULL, and if it isn't, you update the state of the object appropriately (move it forward, backwards, etc). Of course, most objects will have other updates to do, independently of their move instructions.
Objects that don't have a move struct passed can construct one themselves and call the same code to analyze that move and behave appropriately. For an example of this, look at the Player::processTick() method. The code that does that is:
Move aiMove; if (!move && isServerObject() && getAIMove(&aiMove)) move = &aiMove;As you can see, if the move passed is NULL, we replace it with one we calculate on our own (in the getAIMove() function).