35 lines
856 B
C#
35 lines
856 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class ManagerScript : MonoBehaviour
|
||
|
|
{
|
||
|
|
[Header("Spawner Einstellungen")]
|
||
|
|
[SerializeField] private GameObject prefabToSpawn; // Ziehe hier dein Prefab im Inspector rein
|
||
|
|
[SerializeField] private Vector3 spawnPosition = Vector3.zero;
|
||
|
|
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
SpawnObject();
|
||
|
|
}
|
||
|
|
|
||
|
|
void Update()
|
||
|
|
{
|
||
|
|
// Beispiel: Spawnen per Leertaste
|
||
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
||
|
|
{
|
||
|
|
SpawnObject();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void SpawnObject()
|
||
|
|
{
|
||
|
|
if (prefabToSpawn != null)
|
||
|
|
{
|
||
|
|
// Spawnt das Prefab an der Position spawnPosition mit Standard-Rotation
|
||
|
|
Instantiate(prefabToSpawn, spawnPosition, Quaternion.identity);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Debug.LogWarning("ManagerScript: Keinem Prefab zugewiesen!");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|