- Home /
Help with resize script
I want to recreate this:
http://www.emanueleferonato.com/2011/10/25/develop-a-flash-game-like-cirplosion-as3-version-2/
But i cant limit my resize max and min. Why?
var velicina = 10;
var minvelicina = 8;
var maxvelicina = 60;
function Update() {
if(velicina >= maxvelicina)
{
velicina=maxvelicina;
}
if(Input.GetMouseButton(0))
{
transform.localScale += Vector3(velicina,0,velicina)* Time.deltaTime;
}
}
Comment
Best Answer
Answer by Kryptos · Jan 13, 2012 at 10:44 PM
Because you are increasing the value of scale, not the value of velicina.
You may want to do this:
var velicina = 10;
var minvelicina = 8;
var maxvelicina = 60;
function Update() {
if(velicina >= maxvelicina)
{
velicina = maxvelicina;
}
if( Input.GetMouseButton(0 ))
{
velicina += Time.deltaTime;
transform.localScale = Vector3(velicina,0,velicina);
}
}
But spere doesnt scale up when i click mouse button?
Can i write something like if(transform.localScale >= maxvelicina) transform.localScale = maxvelicina ?
well in my solution, the scale might be too big. Try with smaller values.
var velicina : float = 1.0;
var $$anonymous$$velicina : float = 0.8;
var maxvelicina : float = 6.0;
function Update() {
if (Input.Get$$anonymous$$ouseButton(0))
{
velicina += Time.deltaTime;
}
if (Input.Get$$anonymous$$ouseButton(1))
{
velicina -= Time.deltaTime;
}
velicina = $$anonymous$$athf.Clamp(velicina, $$anonymous$$velicina, maxvelicina);
transform.localScale = Vector3(velicina, 0, velicina);
}
Your answer
Follow this Question
Related Questions
OnMouseDown() Doesn't work 17 Answers
MouseDown on GUI.button 4 Answers
Detect Mouse Click OnGUI 1 Answer
How do i make a character move up and down with touch button 0 Answers
Knowing when mouse has been released 2 Answers