problem Changing Scales in Script -C#

Hey , does anybody know if its possible to change Scale through Script in C# ?

I tried by doing

if(Input.GetKey(KeyCode.C)){

transform.LocalScale = new Vector3 (0,-1,0);

}

when it runs this , the Gameobject Gets removed from the scene .

am i doing something wrong here ? or maybe its not possible ?

Thx.

Take a look at your new Vector3 (0,-1,0);

When you press C your object goes from (1, 1, 1) (I’m guessing)

to (0, -1, 0)… Making the X and Z invisible.

try writing transform.LocalScale = new Vector3 (1,-1,1); to see if that works :slight_smile:

You can’t have a 0 scale on more than one axis, since that makes it a 1-dimensional object and therefore not visible.

Ahhh , reading this again … was a pretty dumb question actually

i should probably just let it play an animation instead of messing with scales

Scale refers to the size of the gameobject. Your script won’t work however because you have x=0, z=0 and here’s the killer y= -1. You can’t have a negative value in scale, that means not only does your gameobject not exist, but it actually has negative volume.

try changing the values to positive floats.