lemansky

Untitled

Apr 4th, 2021 (edited)
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Spawner : MonoBehaviour
  6. {
  7.     public float spawnRate = 0.5f;
  8.     public float spawnCooldown = -1f;
  9.     public GameObject enemyPrefab;
  10.  
  11.     void Update()
  12.     {
  13.         if (Time.time > spawnCooldown)
  14.         {
  15.             spawnCooldown = Time.time + spawnRate;
  16.             Instantiate(enemyPrefab, transform.position, transform.rotation);
  17.         }
  18.     }
  19. }
  20.  
Add Comment
Please, Sign In to add comment