For a project I am working on I create some 3D props in Blender that can be put together in a modular way on a 2D grid in Unity. In Unity I generate the grid contents using these props. Now given these two simple shapes (imagine a pipe or railing in top view):


If they are put next to eachother on the grid like so (left):

Joined Sections

I want to make a smooth transition between the two so that their edge vertices align nicely (snap together, see right image above). Note that the angle between the shapes is always the same. However there are variations like straight, left, right for each intersection and also numerous shapes.

How can I achieve this?

I have thought of the following possibilities:

  • Just model each possible variation in blender and use the matching prop when generating the grid (I hope I can avoid this since its a lot of effort, also it's not reusable)
  • Rig the shapes in Blender. In Unity move the bone transforms accordingly so that they align (I like this idea, but is it practical?)
  • (Somehow) mark the vertices on the edge of the shapes and move them to where they belong i.e. modify the mesh in Unity.

Are there other/better ways to achieve this? I appreciate any hints and tips.
I also know I am not the first one to try this so any guidance on where to look for resources and what terms to search for is also appreciated.

  • \$\begingroup\$ Your first option, the one you're trying to avoid, is likely the right solution here. The bone solution means drawing every mesh with a more expensive skinned mesh renderer, even when it's not animating. The dynamic shifting approach would break batching or clutter your memory with duplicate meshes unless you were careful to cache every variant you've generated and re-use them (in which event it's basically option 1 again, just generating the variants in script on demand rather than pre-baked and optimized in advance) \$\endgroup\$
    – DMGregory
    Feb 26 '20 at 12:33
  • \$\begingroup\$ Unfortunately @DMGregory is right. It sounds like what you want to do is essentially what is done with tile mapping. You will likely need to create a model for each type of connection you want and then switch between them with a script depending on how you place them in the scene. If you want to use a non-grid based solution you will likely need to write a script that will slide vertices or position bones to connect the meshes together. This is usually pretty complicated so I wouldn't recommend it unless you are planning on selling this as some asset pack or reusing it everywhere. \$\endgroup\$ Feb 27 '20 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.