How to copy the real size of another sphere gameobject

Hi everyone, i cannot work this out…

I have many spheres in my game, i have a sphere at my cursor and i want to make this sphere match the same size as another sphere in my game when it collides with them.

I have made my spheres in blender3d and they are all scaled to the same scale ( 1, 1, 1 ) in the editor, but visibly they are different in size. So I cannot easily just copy the scale over.

How do i find the true size/scale of another sphere gameobject and then resize it to match its collided sphere object?

this is what i have so far but its not working…

void OnTriggerEnter(Collider other) {
		Debug.Log ("Trigger collidied with: "+ other.gameObject.name.ToString());
		
		if ( other.gameObject.tag == "takesize")
		{
		
			this.transform.localScale = new Vector3 (other.transform.localScale.x,this.transform.localScale.y ,this.transform.localScale.z);
			

			
		}
		
    }

Thanks for your help!

J.

A couple of ideas come to mind. First you can use Bounds.extents of the Mesh.bounds. These values give you the half-width, half-height, and half-depth of the object. You can then calculate the relative size. Here is a bit of code that outputs the extents:

function Update () {
    if(Input.GetKeyDown(KeyCode.A)) {
 		var mesh : Mesh = GetComponent(MeshFilter).mesh;
 		Debug.Log("X:" + mesh.bounds.extents.x + " Y:" + mesh.bounds.extents.y + " Z:" + mesh.bounds.extents.z);
    }
}  

The other way I can think of is to do the calculation by hand and associate the scale factor in a script. Pick one sphere type to be the base size (i.e. factor 1.0). Figure out how all your other sphere types must be scaled to match the size of the base sphere. Put this value in a public variable in a script that you attach to all the spheres. In a collision, use GetComponent() to get this script and then use the value.

Seems would have been easier to make them all the same sizes in blender. But, you could use the parenting trick to make them all the same relative size:

empty parent with script/collider ... scaled 1
   too big size-5 ovaloid, scaled 0.2 so it fits pretty well in a size 1 sphere
   (no one will ever touch the transform of this child)