Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by TheDavil · Sep 14, 2011 at 11:57 AM · prefabspointssnapnodes

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. Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by syclamoth · Sep 14, 2011 at 01:22 PM

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.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TheDavil · Sep 14, 2011 at 02:11 PM 0
Share

Great answer syclamoth - exactly what I was looking for. I'll take a look at the Editor section of the docs as well... Thanks!

avatar image TheDavil · Sep 21, 2011 at 03:34 PM 0
Share

one 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 ?)

avatar image syclamoth · Sep 23, 2011 at 08:43 AM 0
Share

This 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!

avatar image TheDavil · Sep 23, 2011 at 09:29 AM 0
Share

it'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

avatar image TheDavil · Sep 23, 2011 at 09:29 AM 0
Share

oh 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!)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How do I detect intersections on roads that are made out of points? 1 Answer

align building prefab to a road prefab at runtime 0 Answers

Prefab Spawning With SpawnPoints (Loot System) 0 Answers

Points attached to a prefab 0 Answers

Unreal Tournament like points/nodes 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges