Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BugSpawner : MonoBehaviour
- {
- [SerializeField]
- private GameObject bugPrefab;
- [SerializeField]
- private float radius;
- private float spawnTime;
- private Vector3 position;
- // Use this for initialization
- void Start ()
- {
- InvokeRepeating("Spawn", 1, 2);
- }
- // Update is called once per frame
- void Update ()
- {
- position = new Vector3(Random.Range(-1.0f, 1.0f) * radius, 0, Random.Range(-1.0f, 1.0f) * radius);
- }
- private void Spawn()
- {
- Instantiate(bugPrefab, position, Quaternion.identity);
- Debug.Log("Bug");
- }
- private void OnDrawGizmos()
- {
- Gizmos.color = Color.cyan;
- Gizmos.DrawWireSphere(transform.position, radius);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement