So this bug has been driving me crazy. I have an enemy that I want to move back and forth on a given platform--ie, change direction when they hit a wall AND change direction when they find the end of the platform. Its that second part thats giving me trouble.
Here's the collision checking code:
Code: Select all
self.x = self.x + self.v.x
if not self:collide("level", self.x + sign(self.v.x)*self.width, self.y+self.height) or self:collide("level", self.x + sign(self.v.x) , self.y) then
self.v.x = self.v.x * -1
end
That self:collide function is more to make me feel comfortable coming from Flashpunk, it's actually very simple:
Code: Select all
local _,_, cols, len = self.bumpWorld:check(e, x, y, checkingFilter)
for _, v in pairs(cols) do
if (v.other.type == type) then return v.other end
end
return nil
i've turned off any other collision checking and placed my enemy right at ground level. The problem with this is: the enemy moves almost completely off the platform before turning around. and i have absolutely no idea why.
help would be greatly appreciated. and if you need any more details from me, please let me know