Hi, i’m new at using this game framework, so as you read in the title, i was creating various enemy’s to follow my player but after a while of having reached it they stop and stop chasing it but what I want is that they chase it infinitely, here you have my code:
local function distanceBetween( pos1, pos2 )
if (skullVariants ~= nil) then
local factor = { x = pos2.x - pos1.x, y = pos2.y - pos1.y }
return mSqrt( ( factor.x * factor.x ) + ( factor.y * factor.y ) )
end
end
local function _move ()
if (skullVariants ~= nil and player ~= nil) then
local totDist = distanceBetween(skullVariants, player)
local travTime = 1000 * totDist / 500
transition.to ( skullVariants, {x=player.x, y=player.y - 32, time=travTime, 0} )
end
end
Runtime:addEventListener("lateUpdate", _move )