- Home /
Split a sphere (ai) into smaller versions of itself on collision?
I don't have any assets so I'm just using sphere's to work on super basic AI stuff. Sphere's collide into certain types of other spheres. Is there a way to, on collision, destroy itself then instantiate 5 smaller spheres? Would I just have to have 5 smaller spheres anchored to the inside of the single main sphere? The mini spheres won't be particles, they'll just be smaller versions of the larger one.
Answer by Strixie13 · Aug 09, 2018 at 08:40 PM
The best way would probably be to have a smaller sphere prefab. When the object collides, use the instantiate function 5 times, introducing 5 new spheres one at a time. Once it is finished that destroy the main sphere.
Is it possible for me to instantiate them within the sphere at different points? So when the main sphere is destroyed, 5 smaller ones can be instantiated and drop to the ground. I feel like if I instantiated 5 of them at a single point, there would be some weird collision bugs, i.e., one may go flying or they stay clipped together.
Certainly, you can Instantiate any object at any point. Just run through a loop, and for each one put it at a different point so they aren't all together. For example you could do them in a circle spaced around the center object using SIN and COS, or something more simple like a line by increasing the X coordinate every time.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172526im_/https://answers.unity.com/themes/thub/images/avi.jpg)