Updating player when not control object
by Kynan Eng · in Torque Game Engine · 09/29/2005 (3:55 am) · 3 replies
How do we update the player animation when it is not the control object?
I am trying to animate a hand using a glove. I added variables to the MoveManager and the Move struct for this, and the GameConnection's getNextMove updates the Move structure accordingly from the MoveManager.
I have a function in the player class that updates the hand animation according to these variables, which I get in the processTick function, and I've updated packUpdate/unpackUpdate, writePacketData/readPacketData to communicate these variables. (It does this before these functions check if it is the control object and quit if not) It works when the control object is the player. However, when I switch to camera view, updating these MoveManager variables do not animate on the screen until I switch back to the 1/3rd person view, as the processtick is not called.
If I do the update in advanceTime method of the player, this time, every instance of player on a client is applied the same animation according to MoveManager of that client.
Could you help me to find out how to update the client player animations when it is not the control object? Which of the pack/unpack/writePacker/readPacket should I update the internal animation values of the player, and where do I adjust them from the Move Struct, and where do I setMaskBits?
Thanks in advance..
I am trying to animate a hand using a glove. I added variables to the MoveManager and the Move struct for this, and the GameConnection's getNextMove updates the Move structure accordingly from the MoveManager.
I have a function in the player class that updates the hand animation according to these variables, which I get in the processTick function, and I've updated packUpdate/unpackUpdate, writePacketData/readPacketData to communicate these variables. (It does this before these functions check if it is the control object and quit if not) It works when the control object is the player. However, when I switch to camera view, updating these MoveManager variables do not animate on the screen until I switch back to the 1/3rd person view, as the processtick is not called.
If I do the update in advanceTime method of the player, this time, every instance of player on a client is applied the same animation according to MoveManager of that client.
Could you help me to find out how to update the client player animations when it is not the control object? Which of the pack/unpack/writePacker/readPacket should I update the internal animation values of the player, and where do I adjust them from the Move Struct, and where do I setMaskBits?
Thanks in advance..
About the author
#2
Other than that it sounds good.
10/02/2005 (10:55 pm)
You shouldn't need to have an extra update function - just add everything into the existing Move structure and let the system as-is process it.Other than that it sounds good.
#3
separating the new move function was just to avoid applying mouse moves to the player while it is also applied to the camera, which would also work by quitting the normal function after the hand animation moves if the player is not the control object, i guess.
10/04/2005 (4:13 am)
Thanks for the comment... separating the new move function was just to avoid applying mouse moves to the player while it is also applied to the camera, which would also work by quitting the normal function after the hand animation moves if the player is not the control object, i guess.
Torque Owner Kynan Eng
Then, the gameconnection class is added to have set/getPlayerObject as the set/getControlObject stuff, where the updates are done in read/writePacket and read/writeDemoStartBlock of GameConnection class. The setPlayer function is called after the player is created in the server scripts in starter.fps. Then what I do is add a line to GameProcess.cc's advanceObjects method just after where the control object's processtick is called with all the moves in the gameconnections move list, to call the getPlayerObject and call a function to process the hand animation part of the moves, too if it is not already the control object in which case its processtick is already called processing every move. [or better is to enter this GameProcess loop when the object is either controlling or the player, and return after processing hand animations in processtick if it is not the control object]
Now it seems to be working all right. I am not sure whether there is any redundant stuff I've done, or whether I should also update other methods like clientAdvanceTime; but this works for now. Maybe, it would be better in terms of design to have a separate MoveManager like Cory Osborn's separate camera moves, and have the GameProcess call another special function for updating these moves.
Please, do comment if there is mistakes/better ideas...