I found the issue, it has to do with a flag you use: “self-wall_contact”. This flag is unnecessary and leads to your problem:
elseif message.group == group_wall and not self.wall_contact then
print("!!!!!!!!!!!!!HIT WALL!!!!!!!!!!!!!!!!")
handle_wall_contact(self, message.normal, message.distance)
end
You then set the flag to true here:
local function handle_wall_contact(self, normal, distance)
--self.velocity.x = 0
local proj = vmath.dot(self.correction, normal)
local comp = (distance-proj) * normal
self.correction = self.correction + comp
print (self.correction)
print (comp)
print (go.get_position()+comp)
go.set_position(go.get_position()+comp)
--[[
if normal.x ~= 0 then
self.wall_contact = true
self.movement = self.movement*-1
end
]]--
self.wall_contact = true
self.movement = normal.x
proj = vmath.dot(self.velocity, normal)
if proj < 0 then
self.velocity = self.velocity - proj * normal
end
end
This means: you only handle the collision when the skeleton has not hit the wall. Once the skeleton has made the first contact with the wall (and you can get multiple contacts every frame), there is no more collision handling and the skeleton goes through the wall.