How to stop server warping?
by Adam · in Torque Game Engine · 05/07/2007 (9:43 pm) · 1 replies
Hello everyone
I've been working on a new object derived from ShapeBase. This object will be used as sort of an AI bot, it moves around pretty fast navigating the game world. The AI part of the code really isn't an issue, its stopping the warping from server to client that has become a problem. I ended up ripping out the warping code from the item class which helped some but not nearly enough. The only way I found to get around the problem is to do all the calculations on the client. So heres whats happening.
In processTick
I basically just update the velocity based on avoiding collisions in the world, or by seeking after a target. So the velocity changes a little with every processTick. So if I run this calculation for the client and the server the little bot will skip back and forth between positions even with using the warping code from the item class. So my next goal was to just do everything on the server, and still it jumped around like crazy. So I said forget this and derived the little bot from the Item class directly to make sure I wasn't missing anything. That still didn't work so I tried doing the calculations on the client side (which I don't want) and it smoothed it out. All I basically do is setVelocity in processTick which should be handled fairly decent between the server and client.
In all the functions called here I clamp the overall acceleration to 30 units * 32 ms or 0.96. So there is never anymore than a 0.96 change in velocity per call to processTick. Is the problem that the velocity is changing so often for this object? Should I do a linear interpolation or slerp between server update velocities for calculating client velocities?
Any ideas on how to do this. I really don't need the additional overhead that the vehicle class would bring on, and the additional problems with trying to control it with forces.
I hope its just something simple that I'm missing.
Thanks in advance.
I've been working on a new object derived from ShapeBase. This object will be used as sort of an AI bot, it moves around pretty fast navigating the game world. The AI part of the code really isn't an issue, its stopping the warping from server to client that has become a problem. I ended up ripping out the warping code from the item class which helped some but not nearly enough. The only way I found to get around the problem is to do all the calculations on the client. So heres whats happening.
In processTick
I basically just update the velocity based on avoiding collisions in the world, or by seeking after a target. So the velocity changes a little with every processTick. So if I run this calculation for the client and the server the little bot will skip back and forth between positions even with using the warping code from the item class. So my next goal was to just do everything on the server, and still it jumped around like crazy. So I said forget this and derived the little bot from the Item class directly to make sure I wasn't missing anything. That still didn't work so I tried doing the calculations on the client side (which I don't want) and it smoothed it out. All I basically do is setVelocity in processTick which should be handled fairly decent between the server and client.
void Bot::processTick(const Move* move)
{
Parent::processTick(move);
mPosition = getPosition(); //Store the position for easy access
//Do these updates on the Client Side only for now otherwise it skips like crazy
//Not the ideal way to do this :)
if(isClientObject())
{
if( mState == Rotate )
{
//only rotate on the server
this->rotate();
}
else if( mState == Flee)
{
flee();
}
else if(mState == Suicide)
{
suicide();
}
else if(mState == Seek)
{
seek();
}
else
{
//Try to get open
wander();
}
//mVelocity stores the updated velocity
setVelocity(mVelocity);
}
setMaskBits(PositionMask);
}In all the functions called here I clamp the overall acceleration to 30 units * 32 ms or 0.96. So there is never anymore than a 0.96 change in velocity per call to processTick. Is the problem that the velocity is changing so often for this object? Should I do a linear interpolation or slerp between server update velocities for calculating client velocities?
Any ideas on how to do this. I really don't need the additional overhead that the vehicle class would bring on, and the additional problems with trying to control it with forces.
I hope its just something simple that I'm missing.
Thanks in advance.
About the author
Torque Owner Benjamin Buco