Problem with _ Transform.Translate and for cycle

Hey everyone i Made this script, but it have problem
I want to move GameObject that is attached to this script for 4 seconds up, but what it do its count to 4 than counting stops but
GameObject is still moving up… can someone help me pls ?

function Update () {

	for(var n = 0; n < 5; n++)
	{
 		transform.Translate(Vector3(0, 0.1 * Time.deltaTime ,0));
  		  Debug.Log("n is now: " + n);
	}

}

That won’t work because the loop is executing within a single frame. It would be simpler to use a coroutine, such as MoveObject.

–Eric

Thanks for your quick answer :slight_smile: i check out the link

try this transform.Translate(Vector3(0, 0.1 ,0)) * Time.deltaTime;