-1
- 現在、私は簡単な中位の敵を生み出すシステムを持っていますが、私は配列の範囲外のエラーを取得しており、それは唯一の4つの敵を産んでいます。私はしたいX20簡単に(または一般的な数)X20媒体との間で、ランダム
は、これは私のコードである(簡単、ミディアム、ハードの敵。):敵の発動システム。私は簡単な敵がまず最初に召喚され、その後は中位の敵を欲しいと思っています。私はそれが無限のスポーンをしたいです
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
public GameObject[] enemy;
public Transform[] spawnPoints;
private float timer = 2;
int index = 0 ;
int wave = 0;
List <GameObject> EnemiesList = new List<GameObject>();
private int enemyCount=20;
void Update()
{
timer -= Time.deltaTime;
if (timer <= 0 && wave < 6)
{
timer = 3;
if (wave != 0 && wave % 2 == 0)
{
index ++ ;
}
EnemySpawner();
wave++;
}
}
void Spawn()
{
for (int i = 0; i<enemyCount;i++)
{
Invoke("EnemySpawner" , i + 2);
}
}
void EnemySpawner()
{
int spawnPointIndex = Random.Range (0, spawnPoints.Length);
GameObject InstanceEnemies= Instantiate (enemy[index] , spawnPoints[spawnPointIndex].position , spawnPoints[spawnPointIndex].rotation) as GameObject;
EnemiesList.Add(InstanceEnemies);
}
public void Remove (GameObject anything)
{
EnemiesList.Remove (anything);
}
}
非常に一般的な質問については、gamedev.comかanswer.unity3d.comを試してみてください。このサイトは特定のプログラミングに関する質問にのみ対応しています。 – Fattie