Serverside - stop a player from walking after connection drop
by Orion Elenzil · in Torque Game Engine · 06/01/2006 (3:47 pm) · 3 replies
So if i run a server and connect two clients to it,
and then pull the network cable on one of them while they're walking,
the other player sees them "moonwalking" and jittering,
until the server finally times them out and disconnects them,
in stock TGE 1.3, after about 67.5 seconds.
I'd like to alleviate this moonwalking & jittering.
One simple thing would be to reduce the timeout,
which i will do, but i'd like to keep it above say fifteen seconds because sometimes people's connections do in fact come back. (eg, when i plug the network cable back in).
One even better thing would be to just stop the player's motion as soon as the server detects that they *might* be timing out.
I've got code which detects when the client is "possibly losing connection*",
but i don't know how to make the player stop jittering and moonwalking !
I've tried setVelocity(0) and clearMoves() (actually mMoveList.clear()) and both but neither has any effect.
Any clues ?
* I detect "possibly losing connection" as the first missed ping in NetConnection::checkTimeout(),
which seems reasonable. After all, if we haven't heard from the client in 4.5 seconds, it makes some sense to have them stop walking.
TIA
and then pull the network cable on one of them while they're walking,
the other player sees them "moonwalking" and jittering,
until the server finally times them out and disconnects them,
in stock TGE 1.3, after about 67.5 seconds.
I'd like to alleviate this moonwalking & jittering.
One simple thing would be to reduce the timeout,
which i will do, but i'd like to keep it above say fifteen seconds because sometimes people's connections do in fact come back. (eg, when i plug the network cable back in).
One even better thing would be to just stop the player's motion as soon as the server detects that they *might* be timing out.
I've got code which detects when the client is "possibly losing connection*",
but i don't know how to make the player stop jittering and moonwalking !
I've tried setVelocity(0) and clearMoves() (actually mMoveList.clear()) and both but neither has any effect.
Any clues ?
* I detect "possibly losing connection" as the first missed ping in NetConnection::checkTimeout(),
which seems reasonable. After all, if we haven't heard from the client in 4.5 seconds, it makes some sense to have them stop walking.
TIA
About the author
#2
start fading is an interesting idea..
yes, i could do something like that in processTick,
but if possible i'd rather try to simulate as closely as possible the situation where a connected user just takes their hands off the keys & mouse.
i'm thinking maybe pushing a fake move onto the movelist ?
thanks for the reply.
06/01/2006 (4:06 pm)
Hey ramen -start fading is an interesting idea..
yes, i could do something like that in processTick,
but if possible i'd rather try to simulate as closely as possible the situation where a connected user just takes their hands off the keys & mouse.
i'm thinking maybe pushing a fake move onto the movelist ?
thanks for the reply.
#3
06/02/2006 (8:37 am)
Another quickhack is to try sending an animation state change to root (standing/sitting/whichever, I know you have a more complex animation system than stock). At worst, the player might seem to jitter a bit if they aren't actually losing connection, and should return to root and wait for re-connect at best.
Torque Owner Cinder Games
perhaps a
if (!mConnectedToGame)
return;
or
if (LastTimeHeardFrom > 4.5 seconds)
return;
at the very top. you could expand it further by having them fade out as soon as a connection seems lost.