spherecast not working when gameobject are at the same position

i am trying to detect collision using spherecast with following code,

 detectedobjects=Physics.SphereCastAll(transform.position-transform.forward * 0.5f,0.05f,transform.forward,0.8f);

if the gameobjects to be detected are a bit in front of the player, it works.
But if the position of the gameobjects are at the same position with the player,
they cannot be detected.

i also tried to use

detectedobjects=Physics.SphereCastAll(transform.position,0.05f,transform.forward,0.8f);

but this cannot detected everythings, what is the problem?

The area i want to detect is from the position of the player, to a small distant in front of him

That’s the way it should work. The raycast script page: "This function will return false if you cast a ray from inside a sphere to the outside; this in an intended behaviour. " I think sphereCast is the same way. The idea is, if you start from inside something, that’s the one “doing the looking,” and it doesn’t want to see itself.

Either cast from further back, avoiding the player layer, or SphereCastAll backwards along the ray, or do a single overlapSphere (sounds like what you really want – but I’ve never tested the “Bounding volumes only” problem.) Or maybe LineCast (don’t know if it also skips things it starts inside of.)