Okay, I've got a plane with a texture applied to it, and I want to scale the plane according to a sphere collider I have. BEFORE you read ahead, please note that the texture fits perfectly around the sphere collider (texture is a ring) at radius 10 so I have been working around '10', so for example, if the radius equals 9, then Scale / 9 * 10 = The New Scale for that current radius. The problem I'm having is that, at radius 10, the texture fits fine. But if I choose anything lower than 10, so, 9 - the texture grows bigger, not smaller. And vise versa, radius 11 - texture is smaller.
Code:
var RadiusObject : Transform;
private var CurrentSize : float;
private var ScaleX = 2; // These are the texture size when they fit perfectly at 10
private var ScaleY = 0; //--not worried about this, its always 0--\\
private var ScaleZ = 2.3;
private var ScaleXDiv : float = 0; //These are the new scale size
private var ScaleYDiv : float = 0;
private var ScaleZDiv : float = 0;
function Update ()
{
CurrentSize = collider.radius;
ScaleXDiv = (ScaleX / CurrentSize) * 10;
ScaleZDiv = (ScaleZ / CurrentSize) * 10;
RadiusObject.transform.localScale = Vector3(ScaleXDiv,ScaleY,ScaleZDiv);
}