Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Lerp in Coroutine (Crazy Behavior)

$
0
0
Hey my friends i have a problem that i strugle on it for days now , i make an obstacle that goes up and stay some time and return down and stay for some times also, i make it move with the Vector3.lerp function, and to make it stop i use the coroutine yield thing , all work great, but when the time goes and with some duplicante, the obstacles began to move in unsynchronized movements and move with crazy behavior , please help me, it blocks me from advancing in my project this is the code : > IEnumerator Move() { //float timeToStart = Time.deltaTime; while (isAlive) { if (tail.transform.position == currentPoint.position) { pointSelection++; yield return new WaitForSeconds (waitTime); if (pointSelection == points.Length) { pointSelection = 0; waitTime = waitTimeDown; yield return null; } else { waitTime = waitTimeUp; yield return null; } currentPoint = points[pointSelection]; PlaySound (pointSelection); } tail.transform.position=Vector3.Lerp(tail.transform.position,currentPoint.position,speed ); yield return null; } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles