spherecast wont work

var enemyNearing: RaycastHit;
var start : Vector3 = transform.position;

if (Physics.SphereCast(start, view, transform.forward, enemyNearing, 0.000001) && enemyNearing.transform.tag == "EnemyUnit")
{
enemyNear = true;
target = enemyNearing.collider.gameObject.transform.position;
}
else
{
enemyNear = false;
}

This is my code that i am using for the spherecast but for some reason enemyNear isnt becoming true. It seems as though the raycast isnt even firing. How can i fix this?

So the reason this is not working is because SphereCast doesn’t work how you think it does. Spherecast will ignore any colliders that it touches at it’s starting point. It’s meant to detect objects as it moves.

If you want to detect nearby colliders manually you should look into Physics.OverlapSphere. It does not require movement and will detect collisions as you are aiming to do here.

if (hit*.tag == “something”)*
{
// do stuff
}