소환물 프리팹을 SummonPoint에서 랜덤으로 뽑아서 소환하도록 바꿨고
그렇게 하니까 isExistEntity(), 내 코드에선 IsExistDice() 부분에서 이상해서 걍 바꿈
public class SummonPoint : MonoBehaviour
{
public GameObject[] diceObjects;
public GameObject[] bulletObjects;
public Transform[] shotPoints;
public int shotPointChk;
public float maxSpawnDelay;
public float curSpawnDelay;
private int randomDice;
private bool isDice = false;
void Update()
{
curSpawnDelay += Time.deltaTime;
if (curSpawnDelay > maxSpawnDelay)
{
if (IsExistDice())
{
spawnBullet();
maxSpawnDelay = 1f;
curSpawnDelay = 0;
}
}
}
public GameObject SummonOnPoint()
{
randomDice = Random.Range(0, diceObjects.Length);
isDice = true;
return diceObjects[randomDice] = Instantiate(diceObjects[randomDice], transform.position, transform.rotation);
}
void spawnBullet()
{
int randomBullet = Random.Range(0, 1);
int randomPoint = Random.Range(0, 1);
Instantiate(bulletObjects[randomBullet], shotPoints[randomPoint].position, shotPoints[randomPoint].rotation);
}
public void DeleteDice()
{
if (diceObjects[randomDice])
{
Destroy(diceObjects[randomDice]);
diceObjects[randomDice] = null;
}
}
public bool IsExistDice()
{
return isDice;
}
}
그리고 이게 소환 버튼에 들어가는 코드
아마 SummonAction이 SummonDice고
SummonButton이 Summon임
public class Summon : MonoBehaviour
{
public SummonPoint[] summonPoints;
public void SummonDice()
{
int randomPoint = Random.Range(0, summonPoints.Length);
if (summonPoints[randomPoint].IsExistDice())
{
SummonDice();
}
else
{
summonPoints[randomPoint].SummonOnPoint();
}
}
}
암튼 덕분에 해결했다 진짜 고마워 ㅜㅜ 난 이제 보고서 써서 제출해야겠다!
굿
bb
ㅊㅋㅊㅋㅊㅋ~!