Quantcast
Channel: Answers for "Using a while loops to repeatedly execute a method?"
Viewing all articles
Browse latest Browse all 6

Answer by fafase

$
0
0
you need to look into coroutine. At the moment, when the while loop starts it performs the whole movement within the Start method, so you don't see the progression only the final result. With a coroutine, you can leave the method at a point and get back there next frame. In between the object is rendered: void Start(){ StartCoroutine(Move()); } IEnumerator Move(){ float b = 0; while (b < 1) { transform.position = new Vector3 (b + 1, b + 2, 0); b += .01; yield return null; } }

Viewing all articles
Browse latest Browse all 6

Trending Articles