Fill new array with an old array every time two agents collide
I want to fill a new array with an old array from another script when my two agents come close but the fourth time they meet unity crashes and freeze i think my code is correct but i dont know why that happens please help!!!!
void Update{
if (Vector3.Distance (agent1.transform.position, agentother.transform.position)<=2.5f)
{
olddes2 = GameObject.Find("Agent2").GetComponent<RandomMove1>().olddes;
}
}
//thats how i add the array from the other script to my new array
int pos = System.Array.IndexOf (olddes, targetPos2);
int pos2 = System.Array.IndexOf (olddes2, targetPos2);
if (pos > -1 || pos2 > -1) {do something}
//and here i check if a specific value exist in the old or the new array
Comment