Vector3.MoveTowards help :(

hi . i have a code like this and its very good :

var GO:GameObject; var GO2:Transform;
function Update()
{
   GO.transform.position=Vector3.MoveTowards(GO.transform.position,GO2.position,Time.deltaTime*2);
}

But i wana make GO game object donโ€™t change in Y position . i wana GO game object just move for reach X and Z of GO2 !

excuse me for my bad english :slight_smile: if have question , just ask :smiley:

In the Start() method, set InitY = GO.transform.position.y;
In the Update() method,

Vector3 newVec = new Vector3 (GO.transform.position.x, InitY, GO.transform.position.z);
GO.transform.position=Vector3.MoveTowards(newVec,GO2.transform.position,Time.deltaTime*2);