0

This might be a stupid question, but is it possible to use transform.localScale along with acceleration? I can increase/decrease the height of my gameobject on certain keypresses, but I want the scaling to speed up gradually until it reaches a certain speed, and when I release the key I want the scaling to decelerate before it stops completely. Right now my gameobject scales instantly, which is not very realistic.

This is the code I have so far:

void Update() {
    if (Input.GetKey(KeyCode.UpArrow)) {
        transform.localScale += new Vector3(0, 0.1f, 0);
    }
    else if (Input.GetKey(KeyCode.DownArrow)) {
        transform.localScale += new Vector3(0, -0.1f, 0);
    }
}
tootikki
  • 1
  • 3

1 Answers1

0

You need to use Time.deltaTime with some multiplicator in your Update() function to smooth your transformation from frame to frame

Bastien Thonnat
  • 563
  • 4
  • 9