Advertisement
kadyr

Untitled

Oct 10th, 2021
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Spawner : MonoBehaviour
  6. {
  7. public GameObject spawnedObject;
  8.  
  9. private float timer = 0;
  10.  
  11. public float coolDown;
  12.  
  13. void Start()
  14. {
  15. var t = Instantiate(spawnedObject);
  16. t.transform.position = transform.position + new Vector3(Random.Range(-5, 5), 0,
  17. Random.Range(-5, 5));
  18. }
  19.  
  20. void Update()
  21. {
  22. timer += Time.deltaTime;
  23. if (timer > coolDown)
  24. {
  25. var t = Instantiate(spawnedObject);
  26. t.transform.position = transform.position + new Vector3(Random.Range(-5, 5), 0,
  27. Random.Range(-5, 5));
  28. timer = 0;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement