- Home /
Question by
febs1488 · Jun 29, 2012 at 08:46 PM ·
sphereprimitives
How to create a game object (sphere) with all components from a script?
I need to create a sphere from a script with the components of animation, mesh filter, collider, script, mesh renderer
Comment
Answer by Mizuho · Jun 29, 2012 at 08:48 PM
GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
go.AddComponent<Animation>();
go.AddComponent<MeshFilter>();
go.AddComponent<MeshCollider>();
go.AddComponent<MyCustomScript>();
go.AddComponent<MeshRenderer>();
Your answer
![](https://koobas.hobune.stream/wayback/20220613073503im_/https://answers.unity.com/themes/thub/images/avi.jpg)