> For the complete documentation index, see [llms.txt](https://hopemoore.gitbook.io/unity-basics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hopemoore.gitbook.io/unity-basics/translate-rotate-and-scale/scale/updating-scale.md).

# Updating Scale Through Script Code

## Overview

When the game is running, you will not be able to resize objects as you can within the editor, so one way to update the size or scale an object is by updating the object's scale in game units.

The scale values are stored in a vector3 variable with read-only parts, so you cannot update just one axis at a time through transform.localScale.y = 10.0F or something similar. You need to use the keyword new followed by a complete Vector3. Here's an example:

```csharp
// Makes the object 10 game units tall
transform.localScale = new Vector3(0, 10.0F, 0);
```

Here, the game object becomes 10 game units tall. If it starts at 1 x 1 x 1, it appears to jump to that size in one frame and stays at that size until it's resized again.

## Resize Objects by Updating the Local Scale Smoothly Through Code

{% hint style="warning" %}
Avoid using Transform.lossyScale. It controls the global scale of an object, so child objects can be skewed.
{% endhint %}

**Example codes:**

* *Each example should be placed within the Update() or FixedUpdate() function so that it runs once per frame*
* *Each example grows the object it is attached to along the y-axis (gets taller from the center)*

```csharp
transform.localScale += new Vector3(0, 1.0F, 0) * Time.deltaTime;
```

The code above:

1. Accesses the object's transform and then its local scale in game units
2. Uses the += shortcut to add values to itself
3. *new Vector3(float x, float y, float z)* is a way to tell it to add the matching variables
4. *Time.deltaTime* adjusts for varying computer [speeds](/unity-basics/translate-rotate-and-scale/controlling-speed.md)

```csharp
transform.localScale += Vector3.up * Time.deltaTime;
```

The code above:

1. Accesses the object's transform and then its local scale in game units
2. Uses the += shortcut to add values to itself
3. *Vector3.up* is a [shortcut](/unity-basics/translate-rotate-and-scale/handy-transform-shortcuts.md) for Vector3(0.0F, 1.0F, 0.0F);
4. *Time.deltaTime* adjusts for varying computer speeds


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hopemoore.gitbook.io/unity-basics/translate-rotate-and-scale/scale/updating-scale.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
