# How to get correct scale for CircleCollider2D radius?

I working on a pool type 2D game using the new Unity 4.3 2D tools and it appears that I’ve run into a little ditch. To effectively make a shot, I need to locate a point on the circumference of the ball and target same.
The code I use to do this is shown below;

``````Vector2 startPoint  = ConvertTo2D(source.transform.position);
Vector2 targetPoint = ConvertTo2D(target.transform.position);
Vector2 lineOfSight = targetPoint - startPoint;

lineOfSight.Normalize();
if(source.collider2D is CircleCollider2D) {
startPoint = startPoint + lineOfSight *   (CircleCollider2D)source.collider2D).radius;
}
``````

The problem is that the dimension returned for radius from the circle collider is much larger than expected an it appears that this is based on the physics engine simulation and not world space dimensions. How can I easily convert dimensions from physics engine scale to world space?

The best way i have found is to use the largest localscale axis

``````float scaledRadius = Mathf.Max(transform.localscale.x, transform.localscale.y);
``````

Not sure if this is what you’re looking for, but the radius is relative to the object that it is attached to and should be preset to .5. To convert to world space you would multiply the game object’s diameter by the collider’s radius.

Thanks for the response, I eventually found another way around this that didn’t involve physics calculations.

I know this is an old question, but just answering for future reference.

Check the parent’s Scale since it seems that the collider radius scale with it (pretty strange behaviour).