1
\$\begingroup\$

I'm trying to do something that I thought was simple, but seemingly it's not that easy.

I understand that Unity's LOD system works by refering to a percentage of screen size that objects occupy. That's not fit for the isometric 3D game I'm trying to make.

I'd like to have my LODs match the distance from the orthographic camera, as perceived from the viewer. Or, to put it otherwise, that the LODs are set according to their distance from the plane of the camera (and not the camera object itself) multiplied by the orthographic factor. Thus, when the ortho camera zooms out, all objects should swap LODs at the same time.

Is there a simple (or less simple) way to do that ?

Thanks

\$\endgroup\$
1
\$\begingroup\$

If you want to implement your own logic for choosing LOD levels, then you can do so via a script. Use the ForceLOD(int level) method of a LODGroup component to force it to the desired LOD level. Calling the method once will permanently set the LOD level of that gameObject to the stated level. So you only need to call it once per object when changing the camera zoom level.

(In case you want to re-enable the regular LOD logic, call ForceLOD(-1).

\$\endgroup\$
0
\$\begingroup\$

Put this in update ( make sure camera is facing down, i.e. x rotation and y rotation to 90)

  var pos = this.transform.position;
  pos.y = this.GetComponent<Camera>().orthographicSize;
  this.transform.position = pos;

This will solve problem as it will tie camera y world position to orthographicSize, which in orthographic camera won't make a difference, as it doesn't consider camera y position! But the value of orthographicSize is approx to camera y position, then one can calulate vector3 distance between camera and object, now manually set active lod, i.e set active gameobject at whatever distance you like.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.