# SphereCast casts from the circumference, not the center of the sphere

Is this behaviour of Physics.SphereCast correct? I mean, it seems that SphereCast casts starting from the circumference, not the center of the sphere.

For example if you add a sphere to a game object and try this code

``````using UnityEngine;

public class test : MonoBehaviour {

public bool onGroundDown=false;
public bool onGroundLat=false;
public bool onGroundFront=false;
public bool onGroundRear=false;
public float width =0.8f;
Vector3 sphereCenter;
RaycastHit hit;

void FixedUpdate(){
sphereCenter=transform.position;
onGroundDown = Physics.SphereCast(sphereCenter, radius, -transform.up , out hit, radius);
onGroundLat    = Physics.SphereCast(sphereCenter, radius, transform.right , out hit, radius);
onGroundFront = Physics.SphereCast(sphereCenter, radius, transform.forward , out hit, radius);
onGroundRear =  Physics.SphereCast(sphereCenter, radius, -transform.forward , out hit, radius);
}

}

``````

you obtain this result:

Since i want to find all the contact points of a sphere (without using a collider) is there a way to do this using spherecast? To be clear, i want to do something like this:

http://newtondynamics.com/forum/viewtopic.php?f=14&t=5999

UPDATE 11/10/2010 corrected the esposition

There are several things wrong with this question:

1. Spherecast's center is the center that you specify. Of course it's center is different from the transform's center. It has nothing to do with the transform center unless you pass the transform's center as the center of the spherecast when you call it.

2. You assume that the transform position is at the center of the object when it may not be. The transform's position is wherever the pivot is located. It could be below, on top of or even 1000000 units on the x axis away from the center of the object.

3. Physics.Spherecast works exactly as it should. You provide a center point, a radius, a direction to move, (optionally a RaycastHit,) and a distance to sweep. The Physics will move the sphere of the radius provided in the direction provided by the distance provided and if there is a collision, it will return true. Otherwise it will return false.

Whatever it is that you consider "expected behaviour" seems to be mistaken. Perhaps you should explain what it is that you expect to happen. A sphere of radius 0.5 cast a distance of 0.5 in a direction should hit any colliders whose exteriors are positioned between position 0.5 and 1.0 on that axis and whose exteriors are facing the object.

This is what your spherecast is doing:

``````  ____ _ _ _
/    \      \
|   0.5|-0.5->|
\____/_ _ _ /
|---1.0---|

//contact points are the first points at which colliders within the
//sweep area touched the sphere being swept

``````