Jump to content
  • Advertisement
Sign in to follow this  

calculate the time... traslation of object 5mm in 1 sec..

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys..

I am stuck at this point... I couldn't figure it out how to calculate the feedrate and how can I impliment. I have tried alot but now don't know what to do..

Actually the problem is .. I want to translate one object that will cover 5.555 mm in 1 sec.. so it means that 100mm in 18 sec..
I have obtained the results that is 100mm in 18sec but when the fps is 59...

but when I start my simulation, the fps goes to 14... then the object moves very slowly, it does not covers 100mm in 18 sec.. it takes too much time..

my code is..

void ModelRotation_IdleFunc(void)
CurrentTime = clock();
float timeInterval = CurrentTime - PreviousTime;

C_TOOL_X += (5.5555f/(1000.0*3.24*timeInterval*0.001f));

if(C_TOOL_X > 100.0)
C_TOOL_X = C_TOOL_X - 100.0;

PreviousTime = CurrentTime;


kindly guide me how can i do this... I think fps must be considered in my code.. but how ?

Share this post

Link to post
Share on other sites
A basic fps independent movementspeed example:
float stepsize = elapsedTimeSinceLastFrame * speed;
position += stepsize;

This example does work, just try to adjust it so it fits your x meter / second.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!