Topic was automatically imported from the old Question2Answer platform.
Asked By
Wallace99
I’m trying to implement LOD culling with multimeshes but am struggling with being able to compare the distance between my camera and the multimesh. I currently am trying something like this:
but it seems that the aabb is just at the origin? And I can’t find any way to set an AABB, yet in the editor I see what looks like a bounding box around my multi mesh instances as shown in the screenshot below. Is it possible to access this or should I be using a different approach? I just want to be able to calculate the distance between my camera and a multimesh and then show or hide it depending on distance
Ah fixed it by refactoring how I was generating my multiMeshInstances. I had been creating my multiMeshInstances in a strange way by having a scene with a spatial which created a multiMeshInstance in code with its multimesh etc and instancing it in my main scene when generating forests. I must have got a bit mixed up because I refactored to be a multiMeshInstance with a script attached that I instance into my main scene and realised that I can call get_aabb() on it and it does return correctly. Previously I think I had been trying to call get_aabb() before my code had created multimesh and set all the bits and pieces. For anyone interested, this is my code now: