tree sprite added and trying to debug the tree cloning

This commit is contained in:
cemt1363
2026-06-06 13:26:01 +02:00
parent 121dfba58b
commit af293c1a62
4 changed files with 278 additions and 93 deletions
-11
View File
@@ -5,21 +5,10 @@ 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);
}
}