How do u check if something is in a circle?

how do u check if something is in a circle?

Use a magnitude check, as it essentially a spherical hitbox.

If you want a circle specifically (not a sphere), then you’ll want to see if the circle’s Y-position is between the tallest and lowest point of the target model/part. Assuming you want the circle to face upwards.

2 Likes

For 2D:

sqrt(x*x + y*y) <= radius

For 3D:

sqrt(x*x + y*y + z*z) <= radius

etc.

The equality means that you are on the circle boundary. The equations above don’t account for offsets, you will need to add them in if they exist. Eventually what you’re asking for is a distance check(also known as magnitude check).

For boundary checking, you can remove the square root on the left side and use a power of two on your radius. Calculating the square root is a heavy operation. If your radius is constant, then it will help you even more, as you’d store your squared radius in a variable once.

1 Like