i am trying to random generate trees on my island but i want to spawn a gameobject on the same position as the tree can anyone help me with that. this is what i have
If you know that the tree is on, for example, (3, 3) - and you want to put your GameObject there, you want CellToWorld. You’re using WorldToCell.
Something like this should work. I’ve hard coded (3,3), so replace that.
Vector3Int cell = new Vector3Int(3,3,0);
Vector3 worldPosToPutGameObject = Map.CellToWorld(cell);
Instantiate(Treebutton, worldPosToPutGameObject, Quaternion.identity);
Also note that there are interpolated methods for sub-cell accuracy, if you want to place your button in a worldspace position more precisely within a cell.