using UnityEngine; public class TreeSpawner : MonoBehaviour { public GameObject treePrefab; public Transform spawnPoint; private void OnTriggerEnter2D(Collider2D other) { if (!other.CompareTag("Player")) return; Instantiate(treePrefab, spawnPoint.position, Quaternion.identity); } }