- Home /
Gradually scale platform?
I want to have a platform that begins to scale to (about) 0 in width and length once the player walks on top of it, but I want the player to have enough time to walk past this platform before it shrinks completely.
Ignoring the code for the trigger event, how would I gradually scale this platform over some time interval t?
Answer by Eric5h5 · Mar 01, 2010 at 11:20 PM
var startScale = Vector3.one; var endScale = Vector3.zero; var t = 0.0; var speed = .5; while (t < 1.0) { t += Time.deltaTime * speed; transform.localScale = Vector3.Lerp(startScale, endScale, t);
yield;
}
Hello there, this is interesting. would like to know more about this.
I can understand the "var startscale" and var endscale" this set the saiz from size A to B correct. Would like to know why "var startscale" used "vector3.one" and "var endscale" used "vector3.zero", whay does is set like that? can both used "vector3.zero"?
"var speed" is for the "time.deltatime" right, this is for he transtion speed on the "vector3.lerp" correct? but what is "var t"? and why is "t += time.deltaTime * speed" what does this line do actually?
and using "while" will scale the gameobject to the desire size would it? do we need to used "while" to have smooth transtion of the gameobject or there's another method?
in the "transform.localscale" why is there no "+" sign before the "=" sign?
thanks in advance.
Please don't dig up old posts to ask stupid questions. If you have basic program$$anonymous$$g questions to ask, go to google. If you have basic unity-specific questions to ask, use the search-bar at the top-right side of the page. If you still haven't found your answer, open up a new script file, and mess around a bit. If you still can't work out how it all fits together, or you run into a problem, then create a new question, and I'm sure somebody will be there to help you.
Why yes, yes I am stupid. How did you know that. I did search google and used the search bar at the top right side of the page. I also did mess around a bit with the script. I did understand a bit, just would like to know more that is all. If the way I'm asking making you mad I apologize for that. But there's no harm done asking a question, tips, or guideance.
$$anonymous$$aybe no harm done, and Unity3D specific questions are more-than-welcome here, but this Q&A forum isn't intended to serve as a basic program$$anonymous$$g tutorial session. Tips etc is given quite frequently here, I've seen, but this isn't the place to 'ask' for them.
Google should have yielded plenty of results for javascript.
W3Schools.com <-there's one of the many places you can learn scripting/etc basics.
I'm no expert, but I've learned every bit of the web-dev code and all other scripting that I know from w3schools, google searching, and a f**k-load of trial and error (as well as learning a lot here in unityAnswers in the passed month or so)
So you can't tell me you can't find any information in an online search for the questions you posted.
Answer by jorgon · Apr 17, 2012 at 07:03 AM
Please: Why does my instanced prefab appear with my final scale and doesn't do gradually?. I can't write the yield instruction because I'm in an Update function, maybe this is the problem...What would you do with it?. Thanks in adavance.
Answer by RaveTZ · May 08, 2012 at 10:18 PM
LoONuhtiK, seriously. Who are you to dictate who can ask what? The search in google resulted in this page. What google showed me is that being a dick is the result of not being able to provide an answer. Sorry if the question was above your head.
Answer by RaveTZ · May 08, 2012 at 10:30 PM
Seriously? Who are you to dictate who can ask a question in a unity "Answers" forum? The search in google resulted in this page. What google showed me is that being a dick is the result of not being able to provide an answer. Sorry if the question was above your head.