Quantcast
Channel: Latest Questions by Ing3nu
Viewing all articles
Browse latest Browse all 15

Coroutine not running to end?

$
0
0
I am moving an object in Unity3d from point A (the objects current location) to point b (a public Vector3 added through the Inspector. I am using Lerp to handle the movement of the object, and when I place my code under "Update" it works exactly as planned. But I need to make this triggerable (when the number of touches >= 10, this movement is triggered). Coroutines seem to be what I need, and the movement fires as expected, but it isn't running to completion. The object moves a tiny bit, then stops. Could someone point me at my error? I feel like the answer is in the yield statement, but I'm not sure what it should say. Thanks in advance! Code below. ************************************************* void Update() { limitText.text = tapLimit.ToString(); if (Input.GetMouseButtonUp(0)) { tapCount = int.Parse(tapText.text); tapCount += 1; tapText.text = tapCount.ToString(); currentTaps = tapCount; { if(tapCount >= tapLimit) StartCoroutine(EndLevel()); } } } IEnumerator EndLevel() { EndScreen.transform.position = Vector3.Lerp(EndScreen.transform.position, pointB, _t); _t += Time.deltaTime/2; yield return null; }

Viewing all articles
Browse latest Browse all 15

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>