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 Spawning : MonoBehaviour
- {
- public GameObject obstacle;
- private bool spawning = true;
- IEnumerator SpawnItems(){
- while(true){
- if(spawning){
- var obs = ObjectPools.Instance.Get();
- obs.transform.position = obstacle.GetComponent<Transform>().GetChild(Random.Range(0, 4)).position;
- obs.transform.rotation = transform.rotation;
- obs.gameObject.SetActive(true);
- }
- else{
- Instantiate(obstacle);
- }
- spawning = !spawning;
- yield return new WaitForSeconds(10f/PlayerController.speed);
- }
- }
- // Start is called before the first frame update
- void Start()
- {
- StartCoroutine(SpawnItems());
- }
- // Update is called once per frame
- void Update()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement