Gameobject: Difference between revisions
m (→Layers) |
|||
Line 1: | Line 1: | ||
Gameobjects are objects that exist in the scene. They show up in the [[Hierarchy Window]] and can be organized using parent, child and sibling relationships, determined by their position in the hierarchy relative to other gameobjects. Every gameobject has a name, layer, [[Transform Component]] and any other user-added [[:Category:Components|components]]. | Gameobjects are objects that exist in the scene. They show up in the [[Hierarchy Window]] and can be organized using parent, child and sibling relationships, determined by their position in the hierarchy relative to other gameobjects. Every gameobject has a name, layer, [[Transform Component]] and any other user-added [[:Category:Components|components]]. | ||
== Creating | == Creating Gameobjects == | ||
[[File:HierarchyContextMenu.png|thumb|300px|right|The hierarchy right-click context menu.]] | [[File:HierarchyContextMenu.png|thumb|300px|right|The hierarchy right-click context menu.]] | ||
Gameobjects can be created from the hierarchy using the options at the bottom of the right-click context menu. These options can also be accessed from the ''GameObject'' tab in the toolbar. | Gameobjects can be created from the hierarchy using the options at the bottom of the right-click context menu. These options can also be accessed from the ''GameObject'' tab in the toolbar. | ||
''Create Empty'' will create a gameobject with no components attached to it. The gameobject will be created in the root of the hierarchy if nothing is selected, or the ''GameObject'' toolbar menu was used. If right click was used on an object in the hierarchy, the new gameobject will be created as a child | ''Create Empty'' will create a gameobject with no components attached to it. The gameobject will be created in the root of the hierarchy if nothing is selected, or the ''GameObject'' toolbar menu was used. If right-click was used on an object in the hierarchy, the new gameobject will be created as a child of the selected gameobject. | ||
All other options in this menu will create a gameobject, but they will already contain a component. This can save time by not having to manually add common components when making gameobjects. | All other options in this menu will create a gameobject, but they will already contain a component. This can save time by not having to manually add common components when making gameobjects. |
Revision as of 22:29, 15 December 2022
Gameobjects are objects that exist in the scene. They show up in the Hierarchy Window and can be organized using parent, child and sibling relationships, determined by their position in the hierarchy relative to other gameobjects. Every gameobject has a name, layer, Transform Component and any other user-added components.
Creating Gameobjects
Gameobjects can be created from the hierarchy using the options at the bottom of the right-click context menu. These options can also be accessed from the GameObject tab in the toolbar.
Create Empty will create a gameobject with no components attached to it. The gameobject will be created in the root of the hierarchy if nothing is selected, or the GameObject toolbar menu was used. If right-click was used on an object in the hierarchy, the new gameobject will be created as a child of the selected gameobject.
All other options in this menu will create a gameobject, but they will already contain a component. This can save time by not having to manually add common components when making gameobjects.
Using gameobjects
Layers
Gameobjects can be placed onto different layers. Leaving the layer as Default is suitable for most gameobjects. The notable exception to this is any gameobject that will be used as the ground in a Board Mod. These should be set to the WorldGround layer.
Enable/Disable
Similar to components, gameobjects can be enabled and disabled. When a gameobject is disabled, it will be hidden from the scene view and all components attached to it will stop working. You can still select a disabled gameobject from the hierarchy and adjust its Transform in the scene. A gameobject can be re-enabled by selecting its greyed out name in the Hierarchy window, then re-enabling it from the inspector window with it still selected.
Parenting gameobjects
In the hierarchy, dragging a gameobject and releasing it over another gameobject will make it a child of the target gameobject. Child gameobjects will be positioned, rotated and scaled relative to their parent gameobject. This can be used to build hierarchies of gameobjects that move together as a group. You can achieve this simply by creating an empty gameobject and adding other gameobjects as children on the empty parent. Now whenever the parent moves, the children will all move with it.