32 hurts me
by Joobot · in Torque Game Engine · 08/20/2005 (6:24 am) · 2 replies
I have a piece of code here i need some help with:
the AgilityMask is set in a function I have called SetAgility. I use the agility variable as a multiplier for all my speed variables. If I set my agility to 31, the game runs smooth, but if it's 32, the client isn't keeping up with the server, resulting in chuggy gameplay. Here's how the client recieves the data.
and here is the actual function:
How do I make it so it doesn't chug.
if (stream->writeFlag(mask & AgilityMask)) stream->writeInt(mAgility,5);
the AgilityMask is set in a function I have called SetAgility. I use the agility variable as a multiplier for all my speed variables. If I set my agility to 31, the game runs smooth, but if it's 32, the client isn't keeping up with the server, resulting in chuggy gameplay. Here's how the client recieves the data.
if (stream->readFlag())
{
S32 agility = stream->readInt(5);
setAgility(agility);
}and here is the actual function:
void Player::setAgility(S32 value)
{
if(value > 0)
mAgility = value;
else
mAgility = 1;
mMaxForwardSpeed = mDataBlock->maxForwardSpeed * ((mAgility + 20) / 20.0);
mMaxBackwardSpeed = mDataBlock->maxBackwardSpeed * ((mAgility + 20) / 20.0);
mMaxSideSpeed = mDataBlock->maxSideSpeed * ((mAgility + 20) / 20.0);
mMaxUnderwaterForwardSpeed = mDataBlock->maxUnderwaterForwardSpeed * ((mAgility + 20) / 20.0);
mMaxUnderwaterBackwardSpeed = mDataBlock->maxUnderwaterBackwardSpeed * ((mAgility + 20) / 20.0);
mMaxUnderwaterSideSpeed = mDataBlock->maxUnderwaterSideSpeed * ((mAgility + 20) / 20.0);
mJumpForce = mDataBlock->jumpForce * ((mAgility + 20) / 20.0);
mDoubleJumpForce = mDataBlock->doubleJumpForce * ((mAgility + 20) / 20.0);
if(isServerObject())
setMaskBits(AgilityMask);
}How do I make it so it doesn't chug.
About the author
#2
I thought 32 was the first number to use 5 bits, but it's the first to not.
08/20/2005 (11:10 am)
Great, thx.I thought 32 was the first number to use 5 bits, but it's the first to not.
Torque Owner Adam Larson