Attaching 2 rigidbodies,
I need to attach 2 rigidbodies together. I found another question in the forum but it didn't really solve all my doubts. This is the code written by @SpacePilot1000
// Disable collisions with the object being attached
if(Object1.collider2D)
{
Object1.collider2D.enabled = false;
}
// Don't allow physics to affect the object
if(Object1.rigidbody2D)
{
Object1.rigidbody2D.isKinematic = true;
}
// Attach object 1 to object 2
Object1.transform.parent = Object2.transform;
// Center object 1 on object 2 (no offset)
Object1.transform.localPosition = Vector3.zero;
Does this code work with a 3D project?
How can I align the 2 objects in a certain manner before attaching them (preferably using coordinates relative to each other) ?
Can I activate collisions and physics once again to make the new big object interact with the environment?
Does the new object have a name or do I have to name it?
How can I lock one rigidbody in another in a way so that it can rotate in one (or more) direction(s) (like a knee or a shoulder)?
What can I do if I want to attach multiple objects together (3 or more)?
What can I do if I want to detach 2 or more objects?
I know I ask a lot but it's my first game so if you help me you would really make a difference in my project. Sorry for my bad english and thanks for reading!
Your answer
![](https://koobas.hobune.stream/wayback/20220612102932im_/https://answers.unity.com/themes/thub/images/avi.jpg)