Advertisement
sphinx2001

Respawner.cs

Feb 5th, 2021
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Respawner : MonoBehaviour
  6. {
  7.     public float repeat_time;
  8.     public float curr_time;
  9.     public GameObject monster;
  10.  
  11.     void Start()
  12.     {
  13.         curr_time = repeat_time;    
  14.     }
  15.  
  16.     void Update()
  17.     {
  18.         if (GameSystem.MonsterCount <= 0)
  19.             return;
  20.         curr_time -= Time.deltaTime;
  21.         if(curr_time <= 0)
  22.         {
  23.             curr_time = repeat_time;
  24.             Instantiate(monster, transform.position, Quaternion.identity);
  25.             GameSystem.MonsterCount--;
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement