Currently working together with a friend on a survival kind of game where you’re trapped in a supermarket with all the supplied there in the middle of an apocalypse.
Wanted to share a new glass system that I made & get some feedback on it.
Here are two videos:
I’d love to hear what you think & if you have any improvements or questions in mind.
In short, I made a “fracture map” in blender, which contains all the lines that the fracture goes along. Then, when you shoot at the glass, it takes the intersecting area of the glass/shard and the pattern to produce fractured polygons, which then get extruded into 3D pieces. I hope that makes sense.
And yes, then all of those 3D data pieces or whatever you want to call them are converted to editable meshes.
while i acknowledge this work and think it is good, notice it generates a lot of Unions / Intersections, which will pile up real fast and cause stutters if used in the game massively
the very least you must do is detect the glass shard has become motionless, then make it Anchored
There is a lot going on in the background to make sure no lag or stutter is created.
First off, no unions are actually being made, it’s all just a bunch of math. Every editablemesh object needed is already created and just sitting in a pool to reduce the delay of creating those. Then, the MeshParts that are required for the editablemesh are made in separate threads, tho they usually all finish in the same frame.
All the glass shards that fall out eventually anchor & fade away. The time depends on their size. For example, at 23 seconds in the first video, just before I start walking, you can see a tiny shard diagonally right & down from the gun disappear. And once they disappear, instead of destroying them, they are added back to the pool.
Also, the ones that fall out are all already pre-calculated & have their complete mesh and meshpart already sitting in a different pool. Only the shards that touch the edges of the glass that was shot are the ones that need extra calculations & meshes.
Currently, just running around & shooting all the glass I can find, I see no major performance dips. The last optimization thing that I have in mind, that I haven’t added yet, is to start removing older shards immediately if a lot of them start appearing at once, which is what I’m currently working on doing.
And even if it at some point becomes a problem, the way that the glass shatters can fairly easily be changed to contain less shards.