Discord
Login
Community
DARK THEME

Touch Thumb Stick

I'm currently working on a touch thumb stick for agame, but in order to do so, I need to check if you click on a circle.

how would you do collision for circles?

There is a myth passed down by wandering bards that there is powerful mathematics behind such collision detection.

https://microstudio.dev/i/Mythril/circlehitbox/

https://microstudio.dev/i/PaulSt/collisiondetection/

Use the Pythagorean theorem to determine the distance between the center of the circle and the mouse and then compare it to the radius of the circle.

collision_circle_point = function(circle, point)
  local distance = sqrt((circle.x - point.x)^2 - (circle.y - point.y)^2)
  return distance <= circle.radius
end

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community