Seascape/Assets/Scripts/WaveSpawn.cs

56 lines
1.3 KiB
C#
Raw Permalink Normal View History

2025-03-19 10:28:26 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WaveSpawn : MonoBehaviour
{
public PlayerScript playerScript;
//private Vector3 direction = Vector3.up;
[SerializeField] private int maxSpawns = 5;
[SerializeField] private int currentSpawns = 0;
[SerializeField] private float spawnCooldown = 1;
[SerializeField] private float spawnCoolCounter = 0;
public GameObject WaveBullet;
public Transform firePoint;
// Update is called once per frame
void Update()
{
spawnCoolCounter += Time.deltaTime;
//Reguliuert den CurrentSpawn Count
if (spawnCoolCounter > spawnCooldown)
{
if (currentSpawns >= 1)
{
currentSpawns--;
}
spawnCoolCounter = 0;
}
if (Input.GetButtonDown("Fire1"))
{
Debug.Log("Ich versuche zu schie<69>en");
//Pr<50>ft, ob das Limit noch nicht <20>berschreitet ist
if (currentSpawns < maxSpawns)
{
//Debug.Log("Darf was spawnen");
Spawn();
}
}
void Spawn()
{
Instantiate(WaveBullet, firePoint.position, firePoint.rotation);
Debug.Log("Bullet spawnt");
currentSpawns++;
}
}
}