- Home /
Merging Object
I am trying to simple merge 2 spheres together so that they act as 1 rigid body instead of 2. Like they are welded and so that 1 appears indented into the other. All of this happening during runtime. What I am doing is trying to make a POC for solar system simulation in Unity3d. I have the gravity worked out, just not how to merge objects like I said above. I haven't really ever tried anything like this and have no idea where to start. Any help or pointers in the right direction will be appreciated thanks!
A workaround for this may be to merge spheres in a program like $$anonymous$$aya or Blender, and export it/import it to Unity, then add a Rigidbody... pretty complicated workaround...
Answer by Joxno · Aug 17, 2014 at 02:22 AM
You can go about this a couple of ways:
1: Create an empty gameobject, create 2 spheres, move the spheres into the positions that you'd like, and then drag and attach them to the emprty gameobject, and then attach a Rigidbody component to the gameobject.
2: Create 2 spheres, move them into position, drag and attach 1 of the spheres onto the other. Which should have the same effect as the 1st solution.
Well the concept is pretty much the same except that you'd do it in code.
var s1 = new gameObject("Sphere1");
var s2 = new gameObject("Sphere2");
..
$$anonymous$$ove s1 & s2 into positions
..
var go = new gameObject("Body");
s1.transform.parent = go.transform;
s2.transform.parent = go.transform;
go.AddComponent("Rigidbody");
This isn't the full code but I think you get the jist of it
Your answer
![](https://koobas.hobune.stream/wayback/20220613160757im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
destroying game object in a specific transform 2 Answers
how to merge object same as Parent Child ? 1 Answer
Can't Return the Tag of a Child Object 4 Answers
Setting Without Altering Object Scale and Collider Scale 0 Answers
How to add Mesh Collider ? 2 Answers