- Home /
Scale gameObject
I am trying to scale a ship reletive to a variable starting position. It will rotate to a given degree and scale down to a min size then right its rotation. Same when you press the oposite button coming back to scale.
here is what i have so far. How do i scale this correctly? This script will scale my ship, but unlike the rotation script, it scales without pressing the button.
void Update() { float rotation = Input.GetAxis("Vertical") force; float scale = Input.GetAxis ("Vertical") force;
scale *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.localScale += new Vector3(0.1F,0.1f, 0.1f);
transform.Rotate(0, 0, rotation);
}
this will always happen because you have set no condition for it, you can add if(rotation!=0)
before
transform.localScale += new Vector3(0.1F,0.1f, 0.1f);
which incidentally has a capital F on the first float, not sure thats acceptable.
Answer by zak-reynolds · Nov 22, 2014 at 08:13 PM
It looks like a typo:
transform.localScale += new Vector3(0.1F,0.1f, 0.1f);
should be
transform.localScale += new Vector3(scale, scale, scale);
and if that makes it scale too quickly, add in the 0.1f (or whatever speed modifier works right) to the 'scale' calculation at the beginning:
scale *= Time.deltaTime * 0.1f;
Your answer
Follow this Question
Related Questions
Problems with scale and rotation 2 Answers
Transform.Rotate not stopping? 1 Answer
How to prevent Z axis rotation ? 1 Answer
Locking transform, rotation, scale, etc in the inspector window 1 Answer