- Home /
Instantiate three object randomly as one
I have three tennis balls: Ball 1, Ball2, and Ball 3. Each of the tennis balls are seperate prefabs. I want to instantiate a parent tennis ball with the other 2 tennis balls attached to it. It will look kinda like this. The problem is, the positions of the smaller tennis balls need to be set randomly, they can't be predefined. Does anyone have any ideas on how to do this?
Answer by zxc76_die · Nov 04, 2018 at 04:21 AM
I would make a prefab for the inner ball. And shifted it from the center. Then create this object from the prefab. Would give him a parent. And rotated randomly locally.
That sounds great, but it doesn't solve the problem of how to connect the three different objects together.
Answer by James_BadAlchemy · Nov 04, 2018 at 05:20 AM
You can instantiate 4 Objects. On empty GameObject as a parent. Then instantiate the others then assign the empty GameObject as a parent.
I understand basic object instantiation. $$anonymous$$y question was how to procedurally arrange then similar to what was shown in the image.
Your answer
![](https://koobas.hobune.stream/wayback/20220612181501im_/https://answers.unity.com/themes/thub/images/avi.jpg)