Game Development Community

Choppy transition between positions

by Justin Mosiman · in Torque Game Engine · 07/02/2006 (2:18 pm) · 5 replies

Hi,

I'm modifying the RTSCamera from the RTS Starter Kit (my question isn't a specific question to the RTS Starter Kit though, so I'm not posting this in that forum). I have the pitch and yaw modified so that when you do the pitch or yaw, it rotates around a center point. In order for it to rotate around a center point the position has to change, and I am changing the position correctly but it's not smooth at all when changing the position. I have a short video (8 seconds, 544KB) showing this problem at www.opsive.com/uploads/setPosition.avi.

To set the camera position, I call the setCameraPosition with the points that I want to set the position to. Within setCameraPosition, I call setPosition(currPos) and then send it off to update with the server. This is basically it for how the position is set. How can I make the transition between positions smoother? Did I give enough information for this question to be answered?

Thanks,
Justin

Edit: spelling

#1
07/02/2006 (2:40 pm)
Hmmmmm ok. how are you setting the position? via script? hmm probably not. Well i guess it's gonna matter how often you update it. setting the position/transform will only update visually every Tick. you'd need to interpolate the positions somehow
#2
07/02/2006 (2:45 pm)
No, through the engine. Here is the part that sets the position:

void RTSCamera::setCameraPosition(Point2F pos, bool updateNet)
{
   F32 realHeight = getTerrHeight(pos) + mCurrHeight;
   Point3F currPos = Point3F(pos.x, pos.y, realHeight);
   mTargetPos = mPrevPos = Point2F(currPos.x, currPos.y);

   setPosition(currPos);

//Update height/position
}

Since this isn't in the RTS private forum I don't want to post that much about how the RTS Camera works (since this code is basically the same as what you would get from the RTS starter kit)

"you'd need to interpolate the positions somehow" - that is what I was thinking, but do you have any ideas on how?
#3
07/02/2006 (3:13 pm)
Well... what i do myself.... i use the advanced camera resource. And the pathshape resource. generate paths... and attach the camera to the pathshape object. give me some dynamic camera angles.
#4
07/03/2006 (12:03 pm)
Hmm, the advanced camera is setup differently than the RTSCamera, so it would take a lot to import the advanced camera code, and the pathshape resource seems like it would take a lot of tweeking to get it to work with the RTSCamera also.

If I can figure out how to have it interoplate within interpolateTick I think that I would be set, but I've tried a number of things and still haven't been able to smooth it out.
#5
07/03/2006 (8:33 pm)
I have determined the problem to be within processTick(const Move* move). Part of process tick is reproduced below where it determines the direction to move in.
if (move)
   {
      F32 tempX, tempY;
      tempX = move->x * TickSec * mDataBlock->mMovementSpeed;
      tempY = move->y * TickSec * mDataBlock->mMovementSpeed;
 ...
   }

The problem is, is that after setCameraPosition is called, move is never set a value to it, so move->x and move->y equal 0. If I had move equal to an actual number (-1 or 1), it should work correctly. What would be the correct way to solve this? Would it be incorrect to call processTick from within setCameraPosition? I don't even know if that way would work, but I want some input on what the correct way would be to force a move.

Thanks