So I have this large forest of around 2M tris:
Same chunk selected with view on the whole level:
It's been generated within Blender and exported as fbx into Unity. Exporting each tree as an individual object is very performance expensive so the whole forest is split into 2 Objects: Treetrunks and leaves. The Treetrunks all have meshcolliders on them, the leaves obviously don't. (However I do split the forest into chunks as seen above, each chunk roughly 400k tris)
When the Player gets outside visible range of the forest it is disabled, and enabled when the Player gets within a certain range. When it is enabled sometimes it causes a massive lag. When looking into the Profiler it shows this:
Physics? FixedUpdate? The leaves have absolutely no colliders on them, why does it take up Physics.Processing? So I wanted to search further what part of Physics.Processing takes up so much processing time but the top process already shows nothing:
I have an 8 year old GTX760 but it still manages to render the entire forest at 200fps so no, the 2 million Tris are definitely not overkill for my computer.
I've tried this and that and 3 things managed to stop the issue (as seen in the profile screenshots above, the Physics processing time significantly reduced a few frames later)
- Pausing & Unpausing the game or simply Alt-Tabbing outside the Unity Player and back (not always effective)
- Disabling the Player & Reenabling it (almost always effective)
- Starting the Scene with the Player (including Rigidbody, Camera and raycasting scripts) disabled and enabling him a few seconds later via script. (almost always effective) However this only worked if ALL of the forest was set active (roughly 2M tris). If half the forest was disabled on start, and activated after the Player was enabled: LAG.
The Player is the only thing in the game (at this moment) that has a Rigidbody, Raycasting Scripts and a camera.
Things that didn't work:
- Waiting a few minutes
- Disabling & Reenabling the Players Character Controller at any time
- Disabling & Reenabling the camera on the Player at any time.
- Disabling & Reenabling the fucking trees
Anyone got an idea? I'm dumbfounded over here.