Синтаксис:
Используется csharp
using System.Collections;
using UnityEngine;
public class Enem3 : MonoBehaviour
{
public GameObject enemies;
private Vector2[] coordinats = new Vector2[]
{
new Vector2(0, 1),
new Vector2(0, 3),
new Vector2(3, 1),
new Vector2(3, 3),
new Vector2(-3, 1),
new Vector2(-3, 3),
new Vector2(6, 1),
new Vector2(-6, 1),
new Vector2(6, 3),
new Vector2(-6, 3),
};
void Start()
{
StartCoroutine(Spawn());
IEnumerator Spawn()
{
while (true)
{
Vector2 tour = coordinats[Random.Range(0, 10)];
Collider[] intersecting = Physics.OverlapSphere(tour, 0.01f);
if (intersecting.Length == 0)
{
Instantiate(
enemies,
tour,
Quaternion.identity);
yield return new WaitForSeconds(0.5f);
}
}
}
}
}
using UnityEngine;
public class Enem3 : MonoBehaviour
{
public GameObject enemies;
private Vector2[] coordinats = new Vector2[]
{
new Vector2(0, 1),
new Vector2(0, 3),
new Vector2(3, 1),
new Vector2(3, 3),
new Vector2(-3, 1),
new Vector2(-3, 3),
new Vector2(6, 1),
new Vector2(-6, 1),
new Vector2(6, 3),
new Vector2(-6, 3),
};
void Start()
{
StartCoroutine(Spawn());
IEnumerator Spawn()
{
while (true)
{
Vector2 tour = coordinats[Random.Range(0, 10)];
Collider[] intersecting = Physics.OverlapSphere(tour, 0.01f);
if (intersecting.Length == 0)
{
Instantiate(
enemies,
tour,
Quaternion.identity);
yield return new WaitForSeconds(0.5f);
}
}
}
}
}