constance velocity

Additional question sure??
anyone know that formula: displacement = velocity * time

then, how to ensure that, we walk our character with constance velocity
I think, if we use

to update the position.
The questions are:

How can we know that how ofter the position is update?
May the position is depended on how computer fast?

This problem is not needed to be solved if playing in standalone, but multi-player may be? I think

Are any body have good solutions??

Sure, we all know the formula velocity = distance / time.

But we all knot that this formula is not true. It’s just a simplification, for one very special case which is never true: the velocity is constant during the whole time frame.

Some of us know that we can heal the formula, to a good degree, by making the time frame smaller: velocity = dx / dt.

If the time frame is small we can assume that the velocity is constant during the small time frame (or didn’t change “much”).

The smaller dt becomes, the better the formula gets. And when dt becomes zero it becomes true. But now dx/dt is no longer a division, but a mathematical operator called “dervation”. In physics you say the “speed is the derivate of place” (well, non-relativistic physics at least). I don’t want to give lesson on infinitesimal calculus - wikipedia has some easy pages.

Now to Panda3D games and speed. Panda3D engine needs some time to render a frame. When this time is over Panda3D starts computing the next frame. the time Panda3D needs to render a frame is dependent of (1) computer hardware, (2) the scene and camera placement and camera direction. So effectively the time to render a frame is never the same, even of the same machine (I don’t talk about auto-sync, to keep things simpler):

  • dt changes from frame to frame
  • dt is “small”

So we take the “best” formula we have without using calculus:
velcotiy = dx / dt, and make it: dx = veloctiy * dt. Done.

If velocity is constant for several frames this gives a constant movement. And if velocity changes, e.g. because of player input or interaction, the it works too. And it works no matter what computer you have. On slow machines you get bigger computation errors, on fast machines you get smaller computation errors.

enn0x

I think that made it pretty clear but just incase:

By using the dt*self.speed method, we take account of the fact that different computers will loop the main game cycle a different number of times per second (ie their fps will be higher). This is because we find the distance moved by velocity * time (self.speed * dt) since last update, rather than simply moving a certain distance every loop. So if the loop runs once every second (fps = 1) and your character has a speed of 1 metre per second, he will move 1 metre. If it has an fps of 97000, because we use this dt term, he will still only move 1m. (ie dt will be smaller each loop).

In my FPS game; I find the position of the player like here:

posX = self._tempPosX + Move.speed*task.time*cos(radian+direct)
posY = self._tempPosY + Move.speed* task.time*sin(radian+direct)

self._tempPosX and self._tempPosY is the point that i use as reference position before player press the moving buttons

The problem is “when the player need to turn left and right” I need to solve the problem using complex (for me) vector, then I feel stuned,
but its okay.

Second, when is use collisionPusher (use the check if the player hit another object), the result is the worse.

because I do not know when they collid and the collision after collid

last, I think that will be better if i use frequently update using

dx = dx + speedx
dy = dy + speedy

but I am not sure that the possition of the player will depend on the computer performance or not and your answer is yes!!!

so, what can I do??? sure!!!

thank you