Marco Antonio
Marco Antonio

Reputation: 339

Unity 2D: How to make tiles merge with equal textured neighbors?

Let me show you what I mean:
Suppose we have a puzzle game with colored square tiles/blocks falling, and they stack like this:

Individual blocks, individual sprites

My question is, instead of each tile/block sprite stay visually separated from others, what technique can be used to make each tile aware of their neighbors when they stop falling, and change its sprite (and neighbors) to become visually "glued" with them, like this:

Glued blocks, merged sprites

I cant seem to come up with a simple and efficient solution for this, any ideas?

Upvotes: 1

Views: 710

Answers (1)

Ron
Ron

Reputation: 1866

Here are two options that come to mind:

  1. Easier approach - Use a tilemap, each item should have variants for every color and connection in every direction
  2. Harder approach - Build your meshes in realtime and calculate the actual sizes yourself. I think this option could be more robust, but it's much more complex to do (especially if you haven't done something of the sort in the past)

Upvotes: 1

Related Questions