OverlapSphere seems to detect everything and ignores tags. How can I fix this?

I’m trying to set up a per-unit sensor in order to detect when friendly units get near for the unit to follow. However, at the moment I’m using an OverLapSphere. It’s completely ignoring my “Obj.tag” and detecting everything, and not making any sense as to why it should for me.

		targetArray = Physics.OverlapSphere(transform.position, 1.5f, mask.value);
			
		foreach(Collider obj in targetArray)
		{
			if (obj.tag == "ConvoyMember" || obj.tag == "Player")
			{
				followTarget = obj.gameObject;
				
				CancelInvoke("changeDirection");
				transform.parent = null;				
				behaviourMode = behaviour.follow;
				
				break;
			}
		}

One possibility is that the object sending out the OverlapSphere is also a “ConvoyMember”, but it shouldn’t be detecting itself. Is there any way to stop that from occuring?

OverlapSphere has no ability at all to filter by tags; it can only filter by layer. It returns an array of all objects in a radius, so what you do with tags after that is up to you and doesn’t have anything to do with OverlapSphere. Offhand I don’t see anything obviously wrong in the following code, but it depends on other code so it’s hard to say, and is kind of a different question anyway.