0
私はランニングゲームを作っていますが、大きな問題に直面しています。 ステージでは、障害物が作成されます。しかし、しばらくしてから、団結は新たな障害を作りませんでした。なぜこれが起こるのですか?Unity 2D - なぜ敵を作ることができないのですか?
public class GameManager : MonoBehaviour {
public float waitingTime = 1.5f;
public static GameManager manager;
public bool ready = true;
public GameObject cactus;
float time = 0;
// Use this for initialization
void Start() {
manager = this;
}
// Update is called once per frame
void Update() {
time += Time.deltaTime;
//Debug.Log(time);
if(time>2f && ready==true)
{
ready = false;
time = 0;
InvokeRepeating("MakeCactus", 1f, waitingTime);
}
}
void MakeCactus()
{
Instantiate(cactus);
}
public void GameOver()
{
//CancelInvoke("MakeCactus");
iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("x", 0.2, "y", 0.2, "time", 0.5f));
}
}
を解決するpreinstantiatedオブジェクトを表示および非表示にするには、プールを使用し、コストがかかります – Bijan