# Unity, C#, Tutorial 002 , change a object position, rotation and size

August 5, 2011   ·   0 Comments

we will learn how to add a  cube object at the run time, and change position , rotation and  size. This Tutorial will show you how to write a  App in Unity3D, and understand the Unity 3D C# Language to add a  cube object at the run time, and change position , rotation and  size. please step by step to follow below steps to create  your first Unity3D App. open a Tutorial 001 project, and update the code to below. double-click the “addCubeScript”, the editor will show out, unity default is “MonoDevelop” app to do edition. please change the code to below.

```using UnityEngine;
using System.Collections;

// Update is called once per frame
void Update () {

}

void Start() {
// add a new Cube object
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube );
cube.transform.position=new Vector3 (0,2, -5);
cube.transform.Rotate(1,2,3);
cube.transform.localScale=new Vector3 (1.1f,1.2f,1.3f);
}
}
```

description:

1. Line 4:
```cube.transform.position=new Vector3 (0,2, -5);
setup position and location to Cube x=0, y=2, z=-5```
2. Line 12: ` `
```cube.transform.Rotate(1,2,3);
setup Cube rotation to  x=1 degree, y=2 degree, z=3 degree```
3. Line 12: ` `
```cube.transform.localScale=new Vector3 (1.1f,1.2f,1.3f);
setup Cube Scale and size  to  x=1.1f, y=1.2f, z=1.3f
f is float.```
```

Final,
press the "Play" button to start the game. it will look like below picture.``` you can see the new “Cube” attribute in  the Inspector. and double check the value, and you will see the Rotation.x is 0.99999, something the float value is not  1.0f, it  will  change the float value , that is pretty normal. ## Practice：

Please change cube position, rotation and size to different value.

By