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;
1. Does this code work with a 3D project?
2. How can I align the 2 objects in a certain manner before attaching them (preferably using coordinates relative to each other) ?
3. Can I activate collisions and physics once again to make the new big object interact with the environment?
4. Does the new object have a name or do I have to name it?
5. 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)?
6. What can I do if I want to attach multiple objects together (3 or more)?
7. 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!
↧