added tree fab

as well as the scripts, spawntrigger, spawnpoint and tree cloning
This commit is contained in:
cemt1363
2026-06-06 12:21:16 +02:00
parent 5d3a048eea
commit cbfc6e580b
7 changed files with 434 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
using UnityEngine;
public class TreeSpawner : MonoBehaviour
{
public GameObject treePrefab;
public Transform spawnPoint;
private bool hasSpawned = false;
private static float nextAllowedSpawnTime = 0f;
private void OnTriggerEnter2D(Collider2D other)
{
if (!other.CompareTag("Player")) return;
if (hasSpawned) return;
if (Time.time < nextAllowedSpawnTime) return;
hasSpawned = true;
nextAllowedSpawnTime = Time.time + 1f;
Instantiate(treePrefab, spawnPoint.position, Quaternion.identity);
gameObject.SetActive(false);
}
}