- Home /
How to handle collisions for LODs with different submeshes?
I have been trying to understand how collision based functionality can work with different LODs. I have a building prefab which at LOD0 has all of its windows as separate gameobjects, for collision reasons. For performance reasons the final LOD3 prefab is one mesh with the building and all of the windows combined into one.
I have simple projectile collision functionality which when colliding with any window triggers the window's destruction (switching the unbroken window for a broken one). If the projectile strikes the building instead of the window only a decal is created on the surface hit. If a user is standing within range of the LOD0 all is well. However if a user fires a projectile at a window from an LOD3 distance (windows and building combined into one), how can the projectile now trigger that specific window to break? It is my understanding that LODs change based on player distance, therefore how close the projectile is to the window will have no effect on the LOD.
This makes me think that it is only possible to achieve this with the windows and building all separated in every LOD. However at that rate, with one building having an average of 5 windows per floor, an average of 5 floors, that is 25 drawcalls for one building! There must be a better way to optimize this.
So my question is then; how to handle collisions for LODs while still having optimized assets?
Answer by Tanoshimi2000 · Mar 15, 2016 at 04:59 PM
This is just a theory, but since no one else has stepped up...
What if you used the location of the collision to determine if it's a window or a portion of wall. I mean, the collision event returns the point of impact. if your LOD means this is all one item, then you can take the coordinates of the impact, and the script would know locations of windows, and make it a broken window if on the window. Maybe check the building mesh for what's at that position, and if it's nothing, then you know it's a vacancy where a window sits.
As I said, this is theoretical. I could probably whip up some code to try it, but not if you've already solved or quit.