Getting distance moved this frame
-
- Posts: 3
- Joined: Wed Jun 10, 2015 8:22 pm
- Contact:
Getting distance moved this frame
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.
- AndyKorth
- Site Admin
- Posts: 36
- Joined: Wed Aug 15, 2007 3:56 pm
Re: Getting distance moved this frame
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.
-
- Posts: 3
- Joined: Wed Jun 10, 2015 8:22 pm
- Contact:
Re: Getting distance moved this frame
Thanks, that was my first thought but I wasn't sure if there was a "proper" way to do it.
Who is online
Users browsing this forum: Heise IT-Markt [Crawler] and 17 guests