|
|
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- public class spawner : MonoBehaviour
- {
- public GameObject childPrefab;
-
- public float spawnTime;
- private float timer = 0;
-
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
- timer += Time.deltaTime;
-
- float _x = Random.Range(-40, 40);
- float _z = Random.Range(-40, 40);
-
- if (timer > spawnTime)
- {
- var _newChild = Instantiate(childPrefab, new Vector3(_x, 0.5f, _z), Quaternion.identity);
- _newChild.transform.parent = this.transform;
- timer = 0;
- }
- }
-
-
- }
|