- Home /
Question by
Marcos_Bravo · Aug 14, 2018 at 05:46 PM ·
transformscript.floatquaddimensions
Problems with a quad dimensions
So, I have this script that is supposed to change a quad dimensions, it goes like that:
public float IS;
public float xs;
public float ys;
public float zs;
void Start ()
{
xs = this.GetComponent<Renderer>().bounds.size.x;
ys = this.GetComponent<Renderer>().bounds.size.y;
zs = this.GetComponent<Renderer>().bounds.size.z;
}
void Update()
{
IS = gameObject.GetComponentInParent<BaseUnit>().indicatorSize;
this.transform.localScale = new Vector3(IS * xs, IS * ys, IS * zs);
}
IS is a float that returns 1 if the unit is selected and 0 otherwize. I can confirm that those four variables are correct when I play, but they were supposed to change the quad size. If I replace those three last variables with any value it will work as expected, and, as I said, I can confirm they are correct. I tried using three auxiliar variables, they were correct too, but it wouldn't work either. All variables are correct, but no variable seems to work (except for IS times a value), and I can't find why.
Comment
Not a solution, but I believe you can do
private Vector3 xyzs;
private void Start()
{
xyzs = GetComponent<Renderer>().bounds.size;
}
private void Update()
{
float IS = GetComponentInParent<BaseUnit>().indicatorSize;
transform.localScale = IS * xyzs;
}
If this causes errors in other files, you might have some funky stuff going on