Answer the question
In order to leave comments, you need to log in
Why is the code not working. Is it because of FixUpdate and Void Start??
How to make this delay????? I have already tried many ways.
StartCoroutine should not start at the beginning of the scene??
using System.Collections;
using UnityEngine;
public class SpawnBox : MonoBehavior
{
public float miliSecond;
public float second;
public GameObject bomb;
public void FixedUpdate()
{
miliSecond += 0.02f;
if (miliSecond >= 1f)
{
second++;
miSecond = 0f;
}
}
void Start()
{
if (second >= 1f)
{
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(2f);
}
}
}
Answer the question
In order to leave comments, you need to log in
Set up the server. He gives you this page with the titleContent-Type: text/html; charset=windows-1251
The code in Start is executed at the start of the script (roughly speaking) and earlier than FixedUpdate. At this point, second will still be equal to 0. And no coroutine will be executed.
StartCoroutine should not start at the beginning of the scene?? - here without question marks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question