SphereCastAll doesn't works

Hi, I’m trying to use a sherecast but I’ve some problems…
My scene is just a cube and a sphere. The sphere is a moving object and it should get the cube’s collider when it’s in range.

void Update () 
    Vector3 pos = transform.position;
    pos.x += Mathf.Lerp(Time.deltaTime,defaultX,defaultX - 10.0f);
    transform.position = pos;
    RaycastHit[] hits = Physics.SphereCastAll(transform.position,radius,transform.right,0.0f);
    foreach(RaycastHit hit in hits)
    	print("Hit: " + hit.collider.name);

The cube has a collider that is NOT a trigger (according to the documentation).
I’m expect to get the cube hitted by the spherecast but it doesn’t happen.
Any ideas?


have you tried altering the last parameter of the SphereCastAll function to a non-zero value?



the last parameter should mark the distance property to the function.
give it a try :slight_smile: