↑ I uploaded a simple sketch of the concept. I’m trying to find a efficient way to detect the ground surface around the player. so when i press the putton I can spawn some trees at the random position around the player, but of course only on the ground. I’m using the box collider2D as the ground and i have no idea how to approach to this problem. Any suggestion or advice would be really, really appreciated. Thank you:)
2d raycast at random positions near the player… position trees at points of impact of the raycast.
Make sure the ground objects are in a layer of their own, so the raycast can target just that layer.