35 lines
789 B
C#
35 lines
789 B
C#
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;
|
|
}
|
|
|
|
}
|
|
}
|