unity move with transform.position code example

Example 1: unity set position

// To set the position of a gameobject use the following
GameObject.transform.position = new Vector3(x, y, z);

Example 2: unity c# transform position

GameObject myObject;
// Change the position of myObject like this:
myObject.transform.position = new Vector3(x, y, z);
// Change position of GameObject that this script is attatched to:
transform.position = new Vector3(x, y, z);
// Read the x, y and z positions of myObject:
Debug.Log("x : " + myObject.transform.position.x);
Debug.Log("y : " + myObject.transform.position.y);
Debug.Log("z : " + myObject.transform.position.z);

Example 3: unity how to move character using transform

Using UnityEngine;
Using System.Collections;

public class MovementExample : MonoBehaviour

public float speed = 5f;

void update()
{
  	//2D Top Down
	tranform.Translate(Vector3.up * Time.deltaTime * speed);
  	//3D
  	tranfrom.Translate(Vector3.forward * Time.deltaTime * speed);
}

//The more appropriate way to move in 3D is to use a Character Controller on your GameObject!