Hello everyone,
Could you help me find the error in my code that results in the "UnityException: Transform child out of bounds" error.
Here is the faulty line of code as well as unity gameobjects: ![alt text][1]
private IEnumerator GoByTheRoute(int routeNum)
{
coroutineAllowed = false;
Vector2 p0 = routes[routeNum].GetChild(1).position;
Vector2 p1 = routes[routeNum].GetChild(2).position;
Vector2 p2 = routes[routeNum].GetChild(3).position;
Vector2 p3 = routes[routeNum].GetChild(4).position;
while (tParam < 1)
{
tParam += Time.deltaTime * speedModifier;
objectPosition = Mathf.Pow(1 - tParam, 3) * p0 + 3 * Mathf.Pow(1 - tParam, 2) * tParam * p1 + 3 * (1 - tParam) * Mathf.Pow(tParam, 2) * p2 + Mathf.Pow(tParam, 3) * p3;
transform.position = objectPosition;
yield return new WaitForEndOfFrame();
}
tParam = 1f;
routeToGo += 1;
}
[1]: /storage/temp/176475-screen-shot-2021-02-23-at-53642-pm.png
↧