Categories
Unity Scripting

A Simple LOD Handler for Unity

A Level Of Detail Script used for switching out low-poly models for high-poly models as the player approaches the objects for larger scale levels to help with game optimization!

I made this system to help with larger levels in mind to not impact graphics performance. Its rather simple in its function; the LOD_Handler.cs finds all the objects tagged by the developer adds them to a list “allEnvironmentObjects”, then performs a sphere ray cast from the player position, the size of the sphere being adjustable, and if a object in the list is within the sphere cast it adds it to a list “allHitEnvironmentObjects”, then calls a function from the object scripts (low_poly_model.cs & high_poly_model.cs) to activate or deactivate their mesh renderes, dependent on if the plaer is near the object or not.


Check it out below!

The code is freely available on my Github to use!