transform.localPosition Property in Unity

Notes:

transform.localPosition Property in Unity:

Translating game objects using transform.localPosition property:
Translating means changing position of a game object

transform.localPosition:
- stores the position of a game object relative to the parent coordinate system (or parent origin) in the form of Vector3 structure

- is used to get or set position of a game object and move a game object relative to the parent coordinate system (or parent origin)

Note: if there is no parent then world is considered as parent

Example Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Cube1Controller : MonoBehaviour {

// Use this for initialization
void Start () {
/*
Debug.Log (this.transform.localPosition.x);
Debug.Log (this.transform.localPosition.y);
Debug.Log (this.transform.localPosition.z);
*/

//this.transform.localPosition = new Vector3 (10f,0f,0f);

}

// Update is called once per frame
void Update () {
//this.transform.localPosition = this.transform.localPosition + new Vector3 (0f, 0f, 10f) * Time.deltaTime;
this.transform.localPosition += new Vector3 (0f, 0f, 10f) * Time.deltaTime;
}
}