Snap point to point on another prefab

Hi all,

I’m looking for general advice on how best to go about attaching prefabs to other prefabs,

let’s say for example I have a prefab Torso, with nodes/points set for the shoulders (maybe empty game objects),

and I have prefab arms with their own nodes/points that I want to attach to the shoulders and for the prefab to snap correctly point to point ?

I’ve also started thinking what if you had a few room prefabs with doors in certain spots, and if you try to click the rooms together on a grid, the doors would need to line up (so it would be similar to the previous arm-shoulder-socket thing)

also (if possible) - is there a way to combine prefabs into a new prefab ?

I couldn’t find anything in the Answers database because I wasn’t sure how best to phrase the question. In the UDK I think they call this sort of thing ‘sockets’ but in Unity searches, that brings me to a load of networking questions.

Any help at all would be much appreciated - just the general idea, I probably won’t need the code, should be able to figure it out.

I hope I’ve made my idea clear enough.

If all you need is for ‘sockets’ to line up well, try having empty transforms on all the points where you need attachments, and then scripting your objects to align themselves with the empties (possibly setting up transform parents to keep them together). If you need to do something more complex (for example, aligning fully functioning limbs on an existing, invisible skeleton), then things get a little more difficult, but still possible to do. My solution to this problem was to make sure that all the replacement limbs had the same hierarchy and structure, and then in the replacement step checked through the hierarchy of the parent object and made every node a child of the node in the parent with the same name. To detach them, I kept a list of the original transform parents from before they were attached, and reinstated them to return the limb to its original state.

As for your prefabs question, have a look thought the Editor section of the unity documentation- there are several classes and functions to do with prefabs that could be useful to you.