Multiple needs handling and zombie shit
This commit is contained in:
32
3d Prototyp/Assets/Scripts/ZombieSpawner.cs
Normal file
32
3d Prototyp/Assets/Scripts/ZombieSpawner.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Utility;
|
||||
|
||||
public class ZombieSpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
GameObject ZombiePrefab;
|
||||
[SerializeField]
|
||||
private float _spawnRate = 1.0f;
|
||||
[SerializeField, ShowOnly]
|
||||
private float _spawnTimer;
|
||||
|
||||
// Start wird aufgerufen, bevor das erste Frame gezeichnet wird
|
||||
void Start()
|
||||
{
|
||||
_spawnTimer = 60 / _spawnRate;
|
||||
}
|
||||
|
||||
// Update wird einmal pro Frame aufgerufen
|
||||
void Update()
|
||||
{
|
||||
_spawnTimer -= Time.deltaTime;
|
||||
|
||||
if (_spawnTimer <= 0)
|
||||
{
|
||||
Instantiate(ZombiePrefab, transform.position, Quaternion.identity);
|
||||
_spawnTimer = 60 / _spawnRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user