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

Help repeating a coroutine

$
0
0
Hey everybody! I am trying to build an app where the player scrolls through a row of cards by swiping with a finger. I am controlling the movement with a LERP inside a coroutine, and it works perfectly.... Once. On the second, third, fourth swipe, nothing happens. I can see that the swipe motion is registered, but the card no longer moves. I am calling the current position of the card (transform.position) and adding or subtracting 120 (pos1.x = += 120) to set the move-to location for the LERP, could that be where this is going wrong? Any help is appreciated, I've been googling and haven't found the right solution just yet. //swipe left if(currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f) { Debug.Log("left swipe"); StartCoroutine(SwipeLeft()); } IEnumerator SwipeLeft() { pos01.x -= 120; while(_t < 1){ CenterCard.transform.position = Vector3.Lerp(CenterCard.transform.position, pos01, _t); _t += Time.deltaTime/5; Debug.Log("LS"); 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>