Quote:Original post by schragnasher
Basically i add (speed*interpolation) to each value when drawing. Is this correct?
Not sure exactly what you mean, but the basic idea is:
Store the previous position from the last update and the new position after the most recent update:
vec2 last;void update(float dt) // dt is the fixed logic timestep{ last=pos; pos+=speed*dt;}
When rendering, use the following formula to interpolate between the last and current positions based on the interpolation value:
vec2 interpolate(vec2 pos,vec2 last,float blend){ return (pos*blend)+(last*(1.0f-blend));}void render(float blend){ vec2 p=interpolate(pos,last,blend); render_me_at(p);}
Basically the blend factor represents how much time is in the accumulator that there was not time to consume with another timestep, so you are rendering that amount between the previous and current timesteps.