problem with gameobjects after level up

Hello everyone,

  • i am trying to arcade game like
    bubble shooter, when bubbles touch
    each other they destroys if there are
    at least 3 same color objects.
  • I spawn “player” from another
    gameobject(spawner). When player
    touchs other gameobject it destorys
    and spawn next player from another
    script is attached to player.
  • problem is first spawned gameobject
    touchs other gameobject and it is not
    destroys, but second gameobject that
    spawned from player is working good.
    i cannot understand why.
  • i hope i can explain my problem, i
    didnt share my codes because i do not
    think source of problem is code
    because i used same code for spawn
    that two object. i think i cannot
    understand some unity feature.



i realized that problem occurs when level up. the first spawned object after level up is not working. here is my codes:
gameplay manager:

public int y;

void spawnNext(){
	Instantiate(Resources.Load("Player"), new Vector2(0, y), Quaternion.identity);

void Update(){	
	if(GameObject.FindWithTag("Player") == null){

level script:

GameplayManager gameplayManager;

public Text LevelText;

private GameObject player;
private float playerPos;
private int checkpoint, plus, level;

void Start(){
	gameplayManager = GameObject.FindWithTag("GameController").GetComponent<GameplayManager>();
	LevelText.text = "";
	checkpoint = 4;
	plus = 4;
	level = 0;

void Update(){
	player = GameObject.FindWithTag("Player");
	playerPos = player.transform.position.y;
	if(playerPos > checkpoint){
		gameplayManager.y = checkpoint;
		LevelText.text = "LEVEL " + level.ToString();
		plus += 4;
		checkpoint += plus;
		Instantiate(Resources.Load("checkpoint1"), new Vector2(0, checkpoint), Quaternion.identity);

and destroyer script:

void OnTriggerEnter2D(Collider2D other){

	if(other.gameObject.tag == gameObject.tag){
		transform.parent = other.transform;
	if(transform.parent != null && transform.childCount >= 1 && == "Player(Clone)" && other.gameObject.tag == gameObject.tag){
	if(transform.childCount > 1 && other.gameObject.tag == gameObject.tag){

pheww … i higly recomend a “Gameplay Manager” Object. That Manager can check if a Player is spawned or when Player is destroyed you can spawn a new one. Ist higly possible that the two Scripts interact witch each other in a way you didnt thought of.