I’m trying to find a way to check if certain gameobjects (with tag) are within a radius but they don’t have a collider so using overlapsphere isn’t the way. Also I know that I could check the distances between all the gameobjects and determine if they are within the radius, but in this case there will be such a huge number of those gameobjects that I’m worried it will lag my game. Any ideas?
You could just add a collider and set it to IsTrigger. This way, having a box collider or not wouldnt affect the gameobject in any way from a physics perspective, but will allow you to use the OnTriggerEnter(Collision collider)
function. Or you could do a raycast as well. You dont need a collider, as you can check the hit.transform instead of hit.collider. Also Physics.Checksphere can check for gameobjects with a certain layer or layermask. For example:
public Transform GroundCheck; //Empty gameobject that is the center of the sphere
public float GroundDistance = 0.4f; //radius
public LayerMask groundmask; //layer to check for
void Update()
{
bool IsGrounded = Physics.CheckSphere(GroundCheck.position, GroundDistance, groundmask);
}