I want to track it's previous position.
I set a timer and with every second that goes by i get the position of the moving object, the problem is the position keeps updating to the object's current position. that's not what i want. I want it's position one second ago.
I have like 10 ideas on how to do what i want to do, i just think there has to be a simpler and easier way.
the closest i got was a small if statement that inserts the position into a table but again the problem is that the position keeps updating to the current position not the previous one.
Code: Select all
object = {}
object.x = 250
object.y = 200
object.body = love.physics.newBody(world, object.x, object.y, 'dynamic')
object.shape = love.physics.newCircleShape(5)
object.fixture = love.physics.newFixture(object.body, object.shape, 1)
--
object.body:applyForce( 5, 0 )
-- the object is moving to the right, on the x-axis
Code: Select all
function objectTracking()
timer = timer + dt
if timer == 0 then
varPreviousPositionX = object.body:getX()
varPreviousPositionY = object.body:getY()
elseif timer == 1 then
timer = 0
end
end