Skip to content

Instantly share code, notes, and snippets.

@fabriziospadaro
Created June 18, 2018 08:48
Show Gist options
  • Save fabriziospadaro/b9d8265226035ea5e9c046fd7499e902 to your computer and use it in GitHub Desktop.
Save fabriziospadaro/b9d8265226035ea5e9c046fd7499e902 to your computer and use it in GitHub Desktop.
fastest way to get if 2 circles are overlapping
float dx = c2.Position.x - c1.Position.x;
float dy = c2.Position.y - c1.Position.y;
float radii = r1.Radius + r2.Radius;
if ((dx * dx) + (dy * dy) < radii * radii){
return true;
}
else{
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment