doubledamnation icon indicating copy to clipboard operation
doubledamnation copied to clipboard

Soft Merge Collision Merge

Open TheYellowArchitect opened this issue 1 year ago • 0 comments

Hard Merge is the process of merging a single tile onto a vertical/horizontal, and a vertical/horizontal onto a double. TilesLevelEditor This was pretty autistic to do

Soft Merge is the process of merging any tiles together with one or more of their adjacent (of same Y top and bottom), so as to gain performance. This performance gain happens by reducing the total amount of collision boxes. Miniscule gains for a few tiles, but for an entire level, the performance difference is obvious, and this is easily seen comparing the 3 default levels/worlds which have soft merging, compared to any level editor's.

In short, levels that aren't using soft merge, cannot reach huge sizes without reducing FPS below 60. Soft Merge isn't implemented currently, anywhere.

I see 3 implementation ways for Soft Merge. First is for Level Editor, the other 2 are the classic ones.

First

  1. Get adjacent tiles
  2. If top and bottom of current tile (column) is the same as the adjacent, do soft merge
  3. Copy-Paste their sprite renderers Bonus Autism: Make use of triple doubles sprites from default levels
  4. Move towards the equal center distance of adjacent tile(s)
  5. Expand box collision depending on how much the merge happened

Second https://docs.unity3d.com/ScriptReference/Mesh.CombineMeshes.html

Third

  1. Get adjacent collider
  2. Expand one of the 2 colliders, to cover the bounds of the other (so you offset at center, and double size)
  3. Delete covered collider

TheYellowArchitect avatar Aug 11 '22 10:08 TheYellowArchitect