Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
680 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class spawner : MonoBehaviour
  5. {
  6. public GameObject childPrefab;
  7. public float spawnTime;
  8. private float timer = 0;
  9. void Start()
  10. {
  11. }
  12. // Update is called once per frame
  13. void Update()
  14. {
  15. timer += Time.deltaTime;
  16. float _x = Random.Range(-40, 40);
  17. float _z = Random.Range(-40, 40);
  18. if (timer > spawnTime)
  19. {
  20. var _newChild = Instantiate(childPrefab, new Vector3(_x, 0.5f, _z), Quaternion.identity);
  21. _newChild.transform.parent = this.transform;
  22. timer = 0;
  23. }
  24. }
  25. }