- Home /
Problem with finding the right syntax for time.
I'm hoping thats the correct way to phrase this question. I trying to increase an objects size a certain amount over 3 seconds. I have a script to instantiate the prefabed object. This is what I have so far.
var expand : Vector3 = new Vector3 (2,2,2);
function Update () { StopWhen(); }
function StopWhen () { transform.localScale = expand * Time.deltaTime; yield WaitForSeconds (3); Destroy (gameObject); }
Time.deltaTime obviously doesn't work as its the length of time it took to complete the last frame. Time.time doesn't work because after playing for say 30 seconds when you instantiate the object its HUGE because Time.time is the length of time since the game started or something there abouts. What I'm looking for is a syntax for time which means "the length of time since this button was last pressed" I understand that there may not be one (as I'v been lookin for a while now) and that I may have to script the functionality of a timer which starts/resets on a button press. Any help in this matter would be greatly appreciated, I'v put off asking this question and used cheating (not literally just more coding than necessary) and fixes to acheive similar things in similar situations but none of them can achieve the same result for this.
Answer by DaveA · Mar 10, 2011 at 04:37 PM
try transform.localScale += expand * Time.deltaTime;
You sir are a legend, I was so busy trying to mess around with the time syntax that I never thought to try change my equations. Thank you very much.
Your answer
Follow this Question
Related Questions
Checking to see how many times a button was pressed in a certain amount of time? 2 Answers
how to find time of a button pressed 2 Answers
A Question about Dot Syntax... 1 Answer
gui.button down 2 Answers
Scaling dynamic created buttons 2 Answers