The section I used for this portion of the code is based off of the section about one-way platforms
Code: Select all
function Player:onBall() -- checks if the player is on top of the ball or not
self.collider:setPreSolve(function(collider_1, collider_2, contact)
if collider_1.collision_class == "Player" and collider_2.collision_class == "Ballz" then
local heroPos = collider_1:getY() + 48
local ballPos = collider_2:getY() - collider_2:getRadius()
if heroPos >= ballPos then self.grounded = true print(true) else
self.grounded = false
end
end
end)
end