How to find a circle (radius) in grid tiles around another tile

Hey everyone,

I have made a grid system to store some data, and im wondering about the best/most performant approach to find a radius of tiles around a certain tile, or potentially multiple tiles. This radius would need to be scalable, and needs to operate every frame or close to if possible.

I have a few ideas on how to do it but they seem either super heavy or involve manually creating a circle shape for each size.

Some examples would be radius of influence in city builder games, or area of effect for explosions etc in games like xcom. If you have done something similar or have any advice, i’d really appreaciate the help!

Thanks :slight_smile:

If all you need to know is whether objects are within a radius, rather than needing to worry about their specific distance relative to it, you can cut out the Square Root element of Vector Magnitude calculations and stop short at their Square Magnitude instead:

// Example, radius is already cached from (radius * radius) as applicable
if((testedTile.position - middleTile.position).sqrMagnitude < radiusSquared)
{
	// etc.
}