Circle-Rectangle collision side detection in libgdx

前端 未结 2 708
野的像风
野的像风 2020-12-30 10:34

I have spent hours looking for the solution to this: I am developing a little top-down game with libgdx (maybe it matters what engine i am using). Now i have to implement th

2条回答
  •  生来不讨喜
    2020-12-30 11:23

    I suppose you determine the collision by calculating the distance of the circles center with the lines. We can simplify the case and tell that the circle colliding with the corner if both distances are equal and smaller than the radius. The equality should have a tolerance of course.

    More - may be not necessary- realistic approach would be to consider x,y speed and factor it in the equality check.

提交回复
热议问题