Hey guys…whats the best way to control the scale of a object? I want to have the game object be a certain size at start, and then have a “button” control the scale to make it bigger. After a few sceonds i want the object to return to the original size. (Kinda like the car in Jelly Car) Hope thats enough info. Thanks!
Use transform.localScale to adjust the scale. Then combine that with a yield statement to wait a few seconds and return it to its original size.
// Untested forum code!
var SomeGameObject : GameObject;
function OnGUI () {
if (GUI.Button(Rect(5,5,40,20), "Do it!")) {
ExpandThatGO();
}
}
function ExpandThatGO () {
SomeGameObject.transform.localScale = Vector3(2.0, 2.0, 2.0);
yield WaitForSeconds(2);
SomeGameObject.transform.localScale = Vector3(1.0, 1.0, 1.0);
}
Or something like that at least. Should be enough to get you started, let us know if that helps or if you have any more questions!
Thanks alot ! That did the trick!