- Home /
Question by
Ariath · Nov 23, 2013 at 05:30 PM ·
gameobjectzoom
Zoom / enlarge gameobject ?
Hye ! I am looking for code that would allow me to expand a game object when I rolls the mouse. i found this :
var scaleFactor : float = 1.5f;
function OnMouseEnter ()
{
transform.scale *= scaleFactor;
}
function OnMouseExit ()
{
transform.scale /= scaleFactor;
}
But it doesn't work, when i put the script on my game object i have this error : NullReferenceExeption: Object reference not set to an instance of an object
Somebody have an idea ?
PS : really sorry for my bad english.
Comment
Answer by aldonaletto · Nov 23, 2013 at 05:37 PM
It should be transform.localScale instead of transform.scale - despite this error message seems to refer to another problem. Anyway, fix the code and try again.
Answer by Ariath · Nov 23, 2013 at 06:43 PM
Yep, it works fine ! Thank you very much, for your help and your time !
Your answer