I’m trying to make it so the player object, a ball, decreases in size as a timer goes down. It’s supposed to be like a snowball melting. I’ve made a variable to represent the ball’s size so it can change as the timer changes. I’ve tried using transform.localScale a few different ways but the ball is always increasing in size rapidly instead of decreasing slowly. I’ve been trying to avoid posting it on here because I’m a newbie developer and I wanted to try and figure it out on my own. But I’m stuck on this. Any help would be greatly appreciated.
#pragma strict
var maxFallDistance : int = -10;
var ballSize:int;
var timer : float = 10.0;
function Update () {
if (transform.position.y <= maxFallDistance){
Application.LoadLevel ("Tutorial");
}
ballSize = timer;
Debug.Log (ballSize);
timer -= Time.deltaTime;
if(timer <= 0){
timer = 0;
}
transform.localScale += new Vector3(ballSize,ballSize,ballSize);
}
function OnGUI(){
GUI.Box(new Rect(10,10,50,20), "" + timer.ToString("0"));
}
Also please don’t refer me to Unity - Scripting API: Transform.localScale. I tried it and tweaked it a bunch of ways but it kept making it bigger.
Thanks guys
-Nix