So I made a game where enemies follow you but I decided to teleport them away whenever they collide with eachother but when 3 enemies collide at the same time the game crashes.
void OnControllerColliderHit(ControllerColliderHit hit){
//part that does a game over, don't think is relevant
if (hit.gameObject.tag == "Player"){
StartCoroutine(hit.gameObject.GetComponent().callDeath());
}
//part that teleports the enemies away
if (hit.gameObject.tag == "enemy_strong"){
Vector3 NewSpawnPos = new Vector3(characterController.transform.position.z + 30, -0.78f, characterController.transform.position.x +30);
characterController.Move(NewSpawnPos);
}
}
↧