   how to scale an animation over a specific time
  hello, i have the following code executed every frame:current_position += (target_position - current_position) * 0.1;this lets an object smoothly stop at target_position.now, since i dont want to have the animation framedependent, i calculated a variable that runs from 0 to 1 in my specified time.clock = elapsedTime / durationTime;i think i probably have to multiply that variable into the above code, but i dont know where and how.thanks   
  If I understand you correctly, you want an object to smoothly travel a certain distance towards a target point and come to a smooth stop, independently of the frame rate.One way you could do that, that comes to mind, is use a sine function. Make that clock variable run from 0 to Pi/2 instead, and plug it into a sin() function, which will produce a nice curve from 0 to 1 over time. Use that as the position of the object over time. Something like this:// clock runs from 0 to Pi/2 in your specified timecurrent_position = starting_position + (target_position - starting_pos) * Sin(clock);Hope that helps.   ;  I would handle acceleration/deceleration and frame independency separately.You have a way to go along with elapsing time s(t), 0 <= t <= T. How s is chosen has an effect on where the figure start, ends, and how fast it is moved in-between; say acceleration and such is somewhere coded in s. Preferably time t is measured in real-time. The motion starts ... now, meaning that t = t0 is just now. Remember the value of t0 by getting the real-time clock value from your system. Render the frame. Process input. Now it comes to the update of the figure for the next frame rendering. Get the current time and subtract t0, put that value into s(t), and set the figure to that position. Proceed with that until T is reached.So you get the frame time related positionss(0)s(t1)s(t2)...s(T)Of course, normally you will not hit T exactly, so that you have to limit the motion to s(T) for t > T.   ;  my formula:  ((GetClock - Animation_start) mod Animspeed) * (framecounts[Anim_type]) div Animspeed it works smoothly fps independant, no matter what framerate or anything... btw MOD = % C operator, DIV = /.   ;  thank you all for your help!shurcool, the problem is not the animation itself, but the way to make it time-dependent. say i want it to last 13 seconds, then i have a variable that runs from 0 to 1 over 13 seconds.haegarr, i have set up my code the way you suggested, however i still dont know how to get the time variable t into the formula.thanks!   ;  Although it won't have the exact behavior as your function, shurcool's code is correct, you just have to multiply clock by PI/2 in order for [0,1] to scale to [0,PI/2].current_position = starting_position + (target_position - starting_position) * sin(clock * 1.57);An alternative for sin(clock * 1.57) would be pow(clock, x) where x is a number less than 1.[Edited by - jvt9999 on August 7, 2006 5:33:54 AM];  ok, thanks!that would work for a slowing down animation, but in general, how would that work for any other animation?for example a springy animation like this:ani_temp *= 0.98f;ani_temp += (TARGET_POSITION - current_position) * getFrameTime();current_position += ani_temp;(ani_temp starts out with 0)   ;  If your velocity is always constant you can get away with:position += velocity * delta_time;where delta_time = time between frames velocity = displacement per unit timeIf you want to have acceleration, you will have to add this:velocity += acceleration * delta_time;With acceleration, you will notice that you won't get the same results everytime so you might want to read up on these to understand some concepts better:http://en.wikipedia.org/wiki/Euler_integration <-- This is basically what the code above is doinghttp://en.wikipedia.org/wiki/Verlet_integration   