# How do I change an object's scale in code?

**URL:** https://discussions.unity.com/t/how-do-i-change-an-objects-scale-in-code/118912
**Category:** Questions & Answers
**Created:** [October 9, 2014, 5:44am UTC](https://discussions.unity.com/t/how-do-i-change-an-objects-scale-in-code/118912 "2014-10-09T05:44:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vincentamato](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@vincentamato](https://discussions.unity.com/u/vincentamato)
#### Post date: [October 9, 2014, 5:44am UTC](https://discussions.unity.com/t/how-do-i-change-an-objects-scale-in-code/118912/1 "2014-10-09T05:44:34Z")

</div>

Hi. I am making a game where if the player collides with a certain object they’re scale will change. How can I do this? Here’s how I set up the if statement: Now how can I change the scale of the player within that if statement?

```
using UnityEngine;
using System.Collections;

public class GetLonger : MonoBehaviour {

	void OnCollisionEnter(Collision col){
		if(col.gameObject.name == "Biggerer"{

		}
	}
}

```

---

<div class="post-metadata">

### Author: ![Landern](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/landern/32/170836_2.png) [@Landern](https://discussions.unity.com/u/Landern)
#### Post date: [October 9, 2014, 5:48am UTC](https://discussions.unity.com/t/how-do-i-change-an-objects-scale-in-code/118912/2 "2014-10-09T05:48:01Z")

</div>

[transform.localScale](http://docs.unity3d.com/ScriptReference/Transform-localScale.html) is what you’re looking for, just take the current and add in whatever you want through a Vector3.

```
using UnityEngine;
using System.Collections;
 
public class GetLonger : MonoBehaviour {
 
    void OnCollisionEnter(Collision col){
        if(col.gameObject.name == "Biggerer"{
            col.gameObject.transform.localScale += new Vector3(1, 0, 1);
        }
    }
}

```
