Page 1 of 1

Getting distance moved this frame

Posted: Mon Jun 15, 2015 8:00 pm
by tekk
Is there any way to get the distance that a body's moved in the last frame? I'm trying to implement scrolling. Obviously I have my x and y offsets, and when the object being tracked reaches a certain part of the screen, I start to increase the offset by how quickly the body is moving in that direction. The trouble is that I can't figure out how to find it: both GetVelocity and GetForce come up extremely short.

Re: Getting distance moved this frame

Posted: Tue Jun 16, 2015 2:27 pm
by AndyKorth
Try getting the position of the body and comparing it to the position of the body from the previous frame (which you saved in a variable). You can do this in your normal update loop.

Re: Getting distance moved this frame

Posted: Tue Jun 16, 2015 5:30 pm
by tekk
Thanks, that was my first thought but I wasn't sure if there was a "proper" way to do it.