Hi Guys!
When I am destroying a gameobject then just after destroying it i am instaintiating the same type of gameobject too but the problem is when i get collision check for destroying gameobject then my game stops for some time and then destory it and instaintiate it on mobile devices(Android) but it works smoothly on unity.
Here’s My Code:-
if(collision.gameObject.name == “Tanks(Clone)”){
Destroy(collision.gameObject);
GameController.getInstance().OnTruckNTankDestroy();
}
if(collision.gameObject.name == “TruckEnemy(Clone)”)
{
Destroy(collision.gameObject);
Destroy(gameObject);
HelicopterPlayer.missilestopspwan = false;
GameController.getInstance().OnTruckNTankDestroy();
}
public void OnTruckNTankDestroy() {
int random = Random.Range(1,4);
Debug.Log("Range " + random);
switch(random) {
case 1:
CreateTruck();
break;
case 2:
CreateEnemyTruck();
break;
case 3:
CreateEnemyTruck();
break;
case 4:
CreateEnemyTruck();
break;
}
}