วันพุธที่ 23 พฤศจิกายน พ.ศ. 2559

Unity 3D : Go to new position with Corutine


Go to new position with Corutine

using UnityEngine;
using System.Collections;

public class GoToOtherPosition : MonoBehaviour {

public Vector3 d;
int i = 0;

void Start () {

StartCoroutine ( MoveTowardsTarget() );
}

IEnumerator MoveTowardsTarget() {
for(int i = 0 ; i <= 30 ; i++)
{
//yield return new WaitForSeconds(0.005f);
yield return null;
transform.position = new Vector3 (i, 0, 0);

}

}

}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น