I have a gameobject that I wish to move to a specific location.
I can already move the gameobject instantly to a location by using:
transform.position = Vector3(objectPosX,objectPosY,objectPosZ);
However, I would like to see the object move to that position over a bit of time. I have been playing around with the following code.
var speed : float = 5.0;
function Update () {
transform.Translate(Vector3(0,0,speed) * Time.deltaTime);
}
What I don’t understand is how I could move the object to objectPosX,objectPosY,objectPosZ. In the code above I move the object to Vector3(0,0,speed) but Vector3(objectPosX,objectPosY,objectPosZ,speed) clearly doesn’t work. Any help to clarify would be appreciated. Thank you!