# Separating Camera Movement for a first person camera into another thread?

This topic is 1642 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I had a camera working, but it would move every frame, so the higher the framerate, the faster you would be able to move. I made the camera movement so it depends on time, and now the movement is framerate independent. Unfortunately, the function only gets called in the glutMain Loop where the render is also done right after. At 60 FPS, the camera seems a bit jittery, but at 100 frames it seems fine. My question is: Would it make more sense to make a new thread in which there is another game loop where I update physics, etc so movement can be based on time and look nice, regardless of the framerate. (Unless its terrible < 10 because that means there is a code problem or the computer is slow). Any insight or help would be appreciated. Thanks.

##### Share on other sites

seems like you might be doing something wrong... the general pseudo-code is as follows:

velocity = ( current_time - last_render_time ) * factor;

of course, it is best if this is done outside of the render function for precision and accuracy.. but it should still work smoothly regardless

is this basically what you're doing? Or something different?

##### Share on other sites

seems like you might be doing something wrong... the general pseudo-code is as follows:

velocity = ( current_time - last_render_time ) * factor;

of course, it is best if this is done outside of the render function for precision and accuracy.. but it should still work smoothly regardless

is this basically what you're doing? Or something different?

Yes it is, and I believe that  my time is being measured in nanoseconds.

##### Share on other sites

note that current_time probably shouldn't be the actual time function call... you should have something like this:

...

last_render_time = current_time;

current_time = getTime();

...

velocity = ( current_time - last_render_time ) * factor;

...

If you don't have that - try it and see if that makes a difference

##### Share on other sites

note that current_time probably shouldn't be the actual time function call... you should have something like this:

...

last_render_time = current_time;

current_time = getTime();

...

velocity = ( current_time - last_render_time ) * factor;

...

If you don't have that - try it and see if that makes a difference

Did you mean that last render time shouldn't be the function call? Because in your little example, current time is still a function call.

##### Share on other sites

no. i mean that you should set is as a variable first before you use it in the velocity assignment, instead of putting the call right in the velocity assignment statement

##### Share on other sites

no. i mean that you should set is as a variable first before you use it in the velocity assignment, instead of putting the call right in the velocity assignment statement

I see what you mean, in my code I do this.