HardonCollider - resolving collision with a rotated rectangle
Posted: Sat Mar 25, 2023 12:54 pm
Hi, I am attempting to integrate collision detection into my game using HardonCollider and I don’t think I am understanding how to correctly resolve the collisions.
In the attached sample I have a player and a platform. Gravity is constantly applied to the player which makes it fall until it collides with the platform This bit is working ok although I don’t understand why I have to negate the separating vector. The documentation says:
My main issue though is that if I rotate the platform when the player is grounded it sticks to the platform. I can get to around 89 degrees before the player falls off. I would like the gravity to make the player slide down the platform as it rotates. I think this is due to my lack of knowledge of correctly resolving the collision – I think my collision resolution logic is pushing the player against the platform and making it stick.
In the attached sample I have a player and a platform. Gravity is constantly applied to the player which makes it fall until it collides with the platform This bit is working ok although I don’t understand why I have to negate the separating vector. The documentation says:
If the separation vector points in the direction the player has to move shouldn’t it already be negative (to move it up the screen) rather than positive which would push it further into the platform?The separating vector points in the direction that shape has to move to clear the collision
Code: Select all
for shape, delta in pairs(HC.collisions(platform)) do
shape:move(-delta.x, -delta.y)
shape.velocity.y = 0
shape.grounded = true
end