K
K
kostiashka2021-10-17 12:57:45
Unity
kostiashka, 2021-10-17 12:57:45

Do not spawn object after restart what to do?

After the restart button, the object stops spawning here is the code

using System.Collections;
using UnityEngine;

public class SpownBombs : MonoBehaviour
{
    public GameObject bomb;

    void Start ()
    {
        StartCoroutine (Spawn ());
    }

    IEnumerator Spawn ()
    {
        while (!Player.lose)
        {
            Instantiate (bomb, new Vector2 (Random.Range (-2.5f, 2.5f), 5.9f), Quaternion.identity);
            yield return new WaitForSeconds (1.2f);
        }
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Loper47, 2021-10-18
@kostiashka

You probably have Player.lose does not change after reloading the scene.

K
kostiashka, 2021-10-18
@kostiashka

I decided everything instead of Player.lose set true and everything worked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question