I have a script that generates a procedural terrain mesh. In this script, I am also running code that instances trees and places them on the map depending on the biome.
Instead of having the code in a _ready() function, I have an exported button that when pressed, runs my tree and mesh generating function. When clicking the button and running the function, it works as expected. It generates a procedural map and populates the map with trees. When running the scene, however, the trees disappear.
I checked the layering and everything looks good. When hand placing a tree into the scene, that tree shows up when running the scene. Weirdly, its just the instanced trees that aren't showing up.
I also have a function that keeps track of the tree instances and appends them into an array so that I could delete the trees when running the function again. When checking the size of the array some weird things happen. If I check it when generating the mesh and not when running the scene, the size of the array is ~10000 (as expected). When running the scene, the array size is 0. I thought maybe when running the scene, the function that deletes the tree instances is being called for some odd reason, so I deleted that function and tried again, but it didn't change anything. The array is declared outside of any function, so its not redeclaring itself as empty like I thought it might be.
Another thing to note: when clicking into another scene, and then back into the main scene that I am talking about above, the trees disappear in the viewport.
Any suggestions?
In the images below, you'll notice one tree is still there when running the scene, but that's the hand placed tree there to demonstrate that only hand placed objects appear.