SebLague / Solar-System

Simple solar system experiment
https://www.youtube.com/watch?v=7axImc1sxa0
MIT License
1.15k stars 315 forks source link

LOD index/mesh not changing with SetLOD() #46

Closed Panicat closed 2 years ago

Panicat commented 2 years ago

It stays on the highest resolution. I think I understand how the code generally works for this, selecting an LOD mesh from an array with LOD meshes.

Below, you can see that 3 meshes are in fact generated and put into the array:

image

SetLOD() with index 0, 1, or 2, appears to refresh the mesh in game as it disappears for a very brief moment but it's still at the highest resolution, which is LOD index 0.

The active LOD never changes. I did try to change the SetLOD() function a bit so that it is FORCED to change the active LOD but still seems like it doesn't change:

image

The SetLOD() function to show that I have it in its normal state now:

image

If anyone can help it would be appreciated because I need to lower LODs with distance for optimisation reasons. If any more info is required let me know. Thanks.

Delofon commented 2 years ago

Check LODHandler.cs. It automatically changes the LOD of every generator in the scene each frame.

Panicat commented 2 years ago

I'm not sure what exactly I should do with it...?

I finally tried having a Debug.Log in the SetLOD function to print the index it is about to set and it seems to run twice. One time it actually tries to set it to index 2 which I'm trying, then it does 0 again.

Which also explains something I noticed now, that for a VERY brief moment I see the planet being low resolution before going back to full when this runs. So I guess yes, something does set it to 0 although it may just me a mistake of mine.

Panicat commented 2 years ago

By the way I should mention I am not using the SolarSystem scene, and the only reference to LODHandler appears to be in the Solar System scene. So I don't think it's changing stuff here as that scene isn't loaded.

Panicat commented 2 years ago

I think I found it! I was stupid. Thanks for trying to help.

It was the PlanetTest script that was calling that other change back to 0 every time. I commented out the code and I switch between LODs with hotkeys just fine!