campfire/Assets/Scripts/ZSpawner.cs

35 lines
789 B
C#
Raw Permalink Normal View History

2020-04-20 05:11:10 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZSpawner : MonoBehaviour {
public GameObject FloatingZ;
public GameObject Player;
public float Frequency = 5f;
private float TimeUntilSpawn = 8f;
private float spawned = 0;
void Start() {
}
void Update() {
TimeUntilSpawn -= Time.deltaTime;
if (TimeUntilSpawn <= 0) {
if (spawned < 2) {
TimeUntilSpawn = 1f;
spawned++;
} else {
spawned = 0;
TimeUntilSpawn = Frequency;
}
var z = GameObject.Instantiate(FloatingZ, transform.position, new Quaternion());
z.GetComponent<FloatingZ>().Player = Player;
}
}
}