How would I align edges on instantiated prefabs?

Hey all, I have been wanting to make a track maker as a feature in my game, I have the sections that align perfectly as you can see in the pic.

I wanted to know how I would either weld each of the vertices so they snap together, or more realistic, snap the edges together.

I will have it so the user can tap a button, and it will automatically spawn the next track section aligned with the last one.

Any ideas?

Cheers, Tim.

5+ years and no answer… Rats… I was hoping for the answer to this too…
Keep On Creating!

6 years later… (a new player has appeared!)

One way is to place child empties at the center edge of each end of the track and align them by using the empties transform coordinates. then you can lock it onto the empty Objects position.

To make a snap feature you could either raytrace for the nearest empty within x distance or more simply use a temp sphere object for collision detection then fixate the one you moved to the others position.

@jtok4j
@ODNSEV7N
~everyone else who wants the general idea.

Unity always had the vertex snapping feature as far as i can remember (and that goes back to Unity 2.6 in 2011). Just select an object in the sceneview. Now there are two options. Grab the pivot of the object then press and hold “v” to snap that pivot point to another vertex of another object.

However the more useful feature is to first press and hold “v”. Now you can actually “grab” a vertex of the selected object and snap it to another vertex.

Note that when you search for “unity vertex snap” in google the first hit is the Positioning GameObjects documentation page in the manual which mentions vertex snapping at the bottom. There are also several videos (like this one from 2013 or an official one from Unity) which explain how vertex snapping works.

The search took me about 10 seconds (since i’m not that fast on the keyboard). Searching for information requires actual searching.