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.
Thanks
Great answer syclamoth - exactly what I was looking for. I'll take a look at the Editor section of the docs as well... Thanks!
– anon16752599one more question to do with the above - when trying to find nearby sockets, I'm doing a physics.overlapsphere on the 'sockets' layermask (layer 8 I put them on) - but because the 'sockets' are within a prefab the overlapsphere is only getting the prefab collider, should I 'explode' / break the prefab into seperate parts before doing physics.overlapsphere? (and if so, how do I do that ?)
– anon16752599This is a bit out of my depth, I'm afraid- it's not really the way I'd do it, and I'm really not sure how those interactions work!
– syclamothit's ok, I figured it out - you just set transform.parent=null to break the link to a parent, and allow the child to spread its wings, and go forth into the world to find its own crappy job and fend for itself. :-D
– anon16752599oh and the sockets were just empty gameobjects and I couldn't figure out why physics.overlapshere wouldn't find them even on the layermask given, but it was because they didn't have any colliders attached (it took me quite a while to figure that one out!)
– anon16752599