Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class BugSpawner : MonoBehaviour
  6. {
  7.  
  8. [SerializeField]
  9. private GameObject bugPrefab;
  10.  
  11. [SerializeField]
  12. private float radius;
  13.  
  14. private float spawnTime;
  15. private Vector3 position;
  16.  
  17. // Use this for initialization
  18. void Start ()
  19. {
  20. InvokeRepeating("Spawn", 1, 2);
  21. }
  22.  
  23. // Update is called once per frame
  24. void Update ()
  25. {
  26. position = new Vector3(Random.Range(-1.0f, 1.0f) * radius, 0, Random.Range(-1.0f, 1.0f) * radius);
  27. }
  28.  
  29. private void Spawn()
  30. {
  31. Instantiate(bugPrefab, position, Quaternion.identity);
  32. Debug.Log("Bug");
  33. }
  34. private void OnDrawGizmos()
  35. {
  36. Gizmos.color = Color.cyan;
  37. Gizmos.DrawWireSphere(transform.position, radius);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement