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 Spawner : MonoBehaviour
- {
- public GameObject spawnedObject;
- private float timer = 0;
- public float coolDown;
- void Start()
- {
- var t = Instantiate(spawnedObject);
- t.transform.position = transform.position + new Vector3(Random.Range(-5, 5), 0,
- Random.Range(-5, 5));
- }
- void Update()
- {
- timer += Time.deltaTime;
- if (timer > coolDown)
- {
- var t = Instantiate(spawnedObject);
- t.transform.position = transform.position + new Vector3(Random.Range(-5, 5), 0,
- Random.Range(-5, 5));
- timer = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement