Я создал скрипт, который должен вызывать врага каждую 1 секунду. Однако через одну секунду он порождает сотни и не останавливается.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PSpawner : MonoBehaviour
{
public Transform spawny;
public Transform p;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
StartCoroutine("Spawn");
}
public IEnumerator Spawn()
{
yield return new WaitForSeconds(1);
Instantiate(spawny, p.position, Quaternion.identity);
yield return null;
}
}