Game Development Community

Animation On Server

by Joshua "The Power Nap" Taylor · in Torque Game Engine · 06/04/2002 (12:57 pm) · 9 replies

I'm using limb-specific hit boxes, and I'm having trouble getting them to animate on the server.

The hit boxes are based on the bone transformations of the model; they work fine client side, but basically static on the server aside from rotating with the player. They will only animate server side when you fire a weapon, and that's only for a second.

I've set all occurences of animateOnServer to true,and that doesn't help.

If someone could give me a breakdown of the server/cliend animation system, or the animation system as a whole I would be thankfull.

Josh

#1
06/21/2002 (4:08 pm)
Having this *exact* same problem here.

I'm using Josh Albrecht's hitboxes tutorial code and trying to implement a melee weapon swing animation. While the client model hitboxes are animating, the server player boxes only update when the fire weapon button is pushed. I need the server player to mimic the client animation for collision detection purposes.

Does anyone know what exactly is being triggered by the weapon fire code to update the server player animation?

-rob
#2
06/21/2002 (5:41 pm)
I also realize that updating every server player's animation all the time would be a latency nightmare. My goal is simply to have the server player mimic the client player's animation ONLY during the actual weapon swing (there will be a boolean "swing state").

Again, if anyone can shed some light on this, it would be appreciated.

-rob
#3
06/21/2002 (8:37 pm)
long time ago when i used Josh's hitbox code, all animatiosn were synced on the server, even the idle and breathing animations... might wanna check your code again...

--KallDrexx
#4
06/21/2002 (9:43 pm)
You know, I have heard a few similar reports from other people. I believe that GG must have changed something that I relied on in one of the latest versions.

Hmmm... only updated when you fire? That seems to imply to me that this could be somehow tied to the seperation of the first person veiw from the model that GG began a while ago. Try using third person all the time.

I will look into this when I port my code for the newst verison of my tutorial, which is vastly superior to the old one. I will create the tut (the code is finished, but I wanted to test some to make sure it worked before releasing), then I will apply it to a completely fresh copy of the latest torque build, and see if I get the same errors.
#5
06/22/2002 (6:27 am)
There doesn't appear to be any difference in the results between first and third person view. Again, it seems like there's something being triggered by the weapon fire code to cause the server player update. The server player will constantly update if the fire button is held down, though there's a latency that builds over time.

I'd be interested in helping out with testing your new code, Josh. If so, email me at rjcombo@hotmail.com.

-rob
#6
07/12/2002 (8:26 pm)
I've fixed it!

the problem was in the Player::updateAnimation method.

The code was:

---------------------------------------
void Player::updateAnimation(F32 dt)
{
if (isGhost() || mActionAnimation.animateOnServer)
mShapeInstance->advanceTime(dt,mActionAnimation.thread);
if (mRecoilThread)
mShapeInstance->advanceTime(dt,mRecoilThread);

// If we are the client's player on this machine, then we need
// to make sure the transforms are up to date as they are used
// to setup the camera.
if (isGhost()) {
if (getControllingClient()) {
updateAnimationTree(isFirstPerson());
mShapeInstance->animate();
}
else {
updateAnimationTree(false);
}
}
}
--------------------------------------------

and it needs to be:

--------------------------------------------
void Player::updateAnimation(F32 dt)
{
if (isGhost() || mActionAnimation.animateOnServer)
mShapeInstance->advanceTime(dt,mActionAnimation.thread);
if (mRecoilThread)
mShapeInstance->advanceTime(dt,mRecoilThread);

// If we are the client's player on this machine, then we need
// to make sure the transforms are up to date as they are used
// to setup the camera.
//---To get server to animate properly, added <" || mActionAnimation.animateOnServer"> to if-statement---
if (isGhost() || mActionAnimation.animateOnServer) {
//---Joshua Taylor---
if (getControllingClient()) {
updateAnimationTree(isFirstPerson());
mShapeInstance->animate();
}
else {
updateAnimationTree(false);
}
}
}
-------------------------------------------------

This fixed the problem in my build, and it looks as if the if statement could be changed around a bit to get rid of some unneeded function calls.

Anyhoo I thought that I should post this ASAP so people could get on with their projects.


ThunderCats...Hoa!
#7
02/27/2007 (1:40 pm)
I have a related animation question that someone here may be able to help me with. I have a forklift and I am moving the forks via animation. When I run the animation the forks move nicely, but the collision boxes don't update. If the forklift collides with something they do, but they just won't update with the animation. I think the problem is that the animation is running on the client and not updating on the server until a collision occurs. The "animateOnServer" call looks like it might be the answer I'm looking for, but I'm not sure where I should be calling it in my wheeledvehicle, or vehicle code. There isn't an updateAnimation function to stick it in for these classes. Does anyone have any suggestion? Do I need to add this function in? Thanks in advance.

-Don
#8
06/19/2007 (6:32 pm)
@Donald, did you ever resolve your forklift issue? I've got a similar issue.

EDIT - ok I just caught up with you here, adding the shapebase->animate() command seems to be (mostly) working for me too :)
#9
06/21/2007 (7:37 am)
Joe,

That seems to be the best solution I have found. It hasn't created any negative effects that I have seen.

The best place I have found for it is in ShapeBase:processTick() and I added these lines at the very beginning.

if(mShapeInstance)
mShapeInstance->animate();

That seems to do it.

Let me know if you find anything better.