- Home /
Unity Scaling an object from scripts
my script is this...When i scale the object it transform.position gets the same but in the world it shows at different position.
using UnityEngine; using System.Collections;
public class size1 : MonoBehaviour {
// Update is called once per frame
void Update() {
if(abc.Ball1>900 && abc.Ball1<=1000)
{
transform.localScale=new Vector3(1.5f,1.5f,1.5f);
}
else if(abc.Ball1>800 && abc.Ball1<=900)
{
transform.localScale=new Vector3(1.3f,1.3f,1.3f);
}
else if(abc.Ball1>700 && abc.Ball1<=800)
{
transform.localScale= new Vector3(1.1f,1.1f,1.1f);
}
else if(abc.Ball1>600 && abc.Ball1<=700)
{
transform.localScale= new Vector3(.9f,.9f,.9f);
}
else if(abc.Ball1>500 && abc.Ball1<=600)
{
transform.localScale=new Vector3(.7f,.7f,.7f);
}
else if(abc.Ball1>400 && abc.Ball1<=500)
{
transform.localScale=new Vector3(.5f,.5f,.5f);
}
else if(abc.Ball1>300 && abc.Ball1<=400)
{
transform.localScale=new Vector3(.4f,.4f,.4f);
}
else if(abc.Ball1>200 && abc.Ball1<=300)
{
transform.localScale= new Vector3(.3f,.3f,.3f);
}
else if(abc.Ball1>150 && abc.Ball1<=200)
{
transform.localScale= new Vector3(.2f,.2f,.2f);
}
else if(abc.Ball1>=50 && abc.Ball1<=150)
{
transform.localScale=new Vector3(.1f,.1f,.1f);
}
else if(abc.Ball1>0 && abc.Ball1<50)
{
transform.localScale= new Vector3(0f,0f,0f);
}
}
}
probably it is with the pivot point of the gameObject u r using?!
check where the pivot point is !!
i have hacked its pivot from gameobject it give the same result
If you rotate the object around it's Y after you scale it you'll see where the pivot actually is.
Answer by Bunny83 · Dec 21, 2011 at 05:26 PM
The scaling happens always around the objects pivot point. The position is not affected when you change the scale. That sounds like you have set the pivot mode to "center" instead of pivot:
If the mode is set to "center" it shows the "handle" at the objects center instead of its pivot
You are right, you can't set the pivot point in Unity, but in the application you created the object. I'm not an artist so i can't advise you how ;)
i changed the pivot in maya and import it back...thanx
Your answer
Follow this Question
Related Questions
Scaling and performance? 0 Answers
A node in a childnode? 1 Answer
How do you move an object relative to a plane's global scale? 3 Answers
Set plane scaling pivot point? 1 Answer