I wanna know if some of you actually see where my problem is with my function AABB, because when my player goes into the side of a platform, it doesn't block him and let him fall, but it actually let him go into the platform and reach the top of it.
Here is the code and one picture to make it more clear (player is in yellow, platform is in white) :
AABB Function code :
Code: Select all
local function checkCollision(x1, y1, w1, h1, x2, y2, w2, h2)
return x1 < x2 + w2 and
x1 + w1 > x2 and
y1 < y2 + h2 and
y1 + h1 > y2
end
Collision Player Platform code :
Code: Select all
for platformNum, platform in ipairs(platformList) do
if checkCollision(player.x, player.y, player.w, player.h, platform.x, platform.y + player.h, platform.w, platform.h) then
player.vY = 0
end
end
Thanks for your help !
See ya later,
Tilur