- Home /
How to attach rigidbody to another rigidbody at runtime?
Hello. In my game there is situation when i need rigidbody to connect to other rigidbody like a hinge joint. My problem is that hinge joint could not be activated in the midle of the game, and if i leave "connected body" empty it will connect rigidbody to a world coordinate.
So is there a way to attach those? May be there is option to disable hinge joint component until its needed? Or is it possible to add component in runtime through script?
Comment
Best Answer
Answer by Statement · Jan 30, 2012 at 03:19 PM
See GameObject.AddComponent, you can add components runtime as needed.
If you want a "rock solid" bond between your two objects, you could just remove the rigidbody of one of the objects with Destroy(rigidbody) and parent it under the other rigidbody.