- Home /
instantiate a gameobject or rigidbody?
What is the difference between instantiating a gameobject compared to a rigidbody?
Thanks in advance
Answer by kilguril · Nov 20, 2011 at 03:15 AM
Well, these are two completely different things.
In Unity, every single item in the scene is a GameObject, which can be viewed in the scene tree view. Also, all GameObjects have a Transform component attached to them which represents the GameObject position in the scene. Also, the Transform components inherit properties from their ancestors in the object tree. Everything else is a component attached to a GameObject.
If you look at a basic scene, the camera is essentially a GameObject with a Transform component, and a Camera component (and some other components by default). A sound is actually a GameObject - again, with Transform component, and a sound component. And so on.
So basically, whenever you instantiate something, you create a new GameObject with Transform component without even knowing it (it is implied). A Rigidbody is a physics component attached to a GameObject.
If you wanted to instantiate a "bare bones" GameObject, you would instantiate one with Transform component, as it is the minimum requirement for a GameObject to exist.
Also, you have the AddComponent method which adds a said component to an existing GameObject.