i want to know how to make the camera move at the same speed no matter what fps my game runs at.
________
Love advice dicussion
how do i even out the camera speed with the fps?
-
- Posts: 38
- Joined: Tue Aug 21, 2007 6:54 pm
- Contact:
how do i even out the camera speed with the fps?
Last edited by wREAKAILDRON on Tue Feb 22, 2011 6:52 am, edited 1 time in total.
-
- Posts: 38
- Joined: Tue Aug 21, 2007 6:54 pm
- Contact:
i wanted to erase this and post another question now, i did it a different way too and got a smooth result. should i give the answer? ?
i did it by dividing the frame rate by 1 and multiplying it by either 100 or 1000, and now the camera moves at the same speed for different framerates.
________
UNIVERSAL HEALTH WAREHOUSE
i did it by dividing the frame rate by 1 and multiplying it by either 100 or 1000, and now the camera moves at the same speed for different framerates.
________
UNIVERSAL HEALTH WAREHOUSE
Last edited by wREAKAILDRON on Tue Feb 22, 2011 6:52 am, edited 1 time in total.
That's the same thing. All you did was get the delta from the frame rate instead of from the ... well, original delta.wREAKAILDRON wrote:i wanted to erase this and post another question now, i did it a different way too and got a smooth result. should i give the answer? ?
i did it by dividing the frame rate by 1 and multiplying it by either 100 or 1000, and now the camera moves at the same speed for different framerates.
For example, 60 fps:
1 / 60 = 0.016 seconds per frame (your delta)
You must've multiplied it by 1000 because it's kinda small and unnoticeable (move from seconds to kiloseconds or so).
This isn't good solution.
This is code from CFPSCounter.cpp:
As you can see fps is update only one time in 1500ms. So you camera can "jump" if framerate will change for short time. For example you can get 30 fps when player is looking at fire for 10 second, and 60 when he tourn around, but for first 1500ms camera can move faster.
You should always check time each frame.
This is code from CFPSCounter.cpp:
Code: Select all
//! to be called every frame
void CFPSCounter::registerFrame(u32 now, u32 primitivesDrawn )
{
++FramesCounted;
PrimitiveTotal += primitivesDrawn;
PrimitivesCounted += primitivesDrawn;
Primitive = primitivesDrawn;
const u32 milliseconds = now - StartTime;
if (milliseconds >= 1500 )
{
const f32 invMilli = core::reciprocal ( (f32) milliseconds );
FPS = core::ceil32 ( ( 1000 * FramesCounted ) * invMilli );
PrimitiveAverage = core::ceil32 ( ( 1000 * PrimitivesCounted ) * invMilli );
FramesCounted = 0;
PrimitivesCounted = 0;
StartTime = now;
}
}
You should always check time each frame.