Ambiguous 3D Motion
by Kirk Haynes · in Torque Game Engine · 09/08/2006 (1:21 pm) · 1 replies
I'm trying to implement generic reference motion into a 3D object, that doesn't require constant position updates from the server to the client, but it doesn't seem to be synchronizing properly between server and client, and I don't know why. When I step through the code the values all work out correctly but the positon on the client isn't what it's supposed to be at the end, after some kind of hickup.
I inititilize the motion on the server object.
It was suggested that I may need to integrate this with interpolateTick and warpticks to make it come out correctly. How do I do that?
I inititilize the motion on the server object.
void MotionItem::NewMotion( VectorF & motion, S32 ticks)
{
mMotion = true;
mMotionVector = motion;
mMotionTicks = ticks; // used to send the value unaltered to the client
mMotionTicksRemaining = ticks; // used by processTick
setMaskBits( MotionMask);
}
U32 MotionItem::packUpdate( NetConnection * connection, U32 mask, BitStream * stream)
{
U32 retMask = Parent::packUpdate( connection, mask, stream);
if ( stream->writeFlag( mask & MotionMask) )
{
mathWrite( *stream, mMotionVector);
stream->writeInt( mMotionTicks, 9);
}
return retMask;
}
void MotionItem::unpackUpdate(NetConnection *connection, BitStream *stream)
{
Parent::unpackUpdate( connection, stream);
if ( stream->readFlag() ) // MotionMask
{
mMotion = true;
mathRead( *stream, & mMotionVector);
mMotionTicksRemaining = stream->readInt( 9);
}
}
void MotionItem::processTick( const Move * move)
{
Point3F position;
MatrixF transform = mObjToWorl;
position = transform.getPosition();
if ( mMotion )
{
position += mMotionVector;
--mMotionTicksRemaining;
if ( mMotionTicksRemaining <= 0 )
{
mMotion = false;
}
transform.setPosition( position);
Parent::setTransform( transform);
}
}It was suggested that I may need to integrate this with interpolateTick and warpticks to make it come out correctly. How do I do that?
Torque Owner Kirk Haynes