Skip to main content
A GameObject is the basic building block of every scene. It has a name, a transform (position, rotation, and scale), and a list of child GameObjects. On its own it does nothing; you attach Components to add behavior.
// Create a new GameObject in the active scene
var go = new GameObject( "My Object" );

// Add a component
var renderer = go.AddComponent<ModelRenderer>();

// Destroy it later
go.Destroy();

Properties

Id
Guid
A unique identifier for this GameObject. Assigned at creation and stable for the lifetime of the object. Used internally for scene directory lookups and networking.
Name
string
Display name. Defaults to "GameObject" if not set. Setting to null silently resets it to "Untitled Object".
go.Name = "Player";
Log.Info( go.Name ); // "Player"
Enabled
bool
Whether this GameObject wants to be active. Setting this to false disables the object and all its components without removing them from the scene. Children are also disabled.
Enabled reflects what you set, not whether the object is truly active. Use Active to check whether the object is actually running.
Active
bool
True when the object is enabled, in a scene, not network-culled, and every ancestor is also enabled. Components only tick when Active is true.
if ( go.Active )
    Log.Info( "Object is running" );
IsValid
bool
True if the object has not been destroyed and still belongs to a scene. Check this before using any reference that may have become stale.
if ( target.IsValid() )
    target.Destroy();
IsDestroyed
bool
True if Destroy() has been called, even before the actual destruction happens at the start of the next frame.
Parent
GameObject
The parent of this object in the hierarchy. Setting to null re-parents to the scene root. Cannot be set on a Scene object.
// Re-parent while keeping world position
go.SetParent( newParent, keepWorldPosition: true );
Children
List<GameObject>
The direct children of this object. Do not modify this list directly — use SetParent on the child instead.
Scene
Scene
The scene this object belongs to. Becomes null after the object is destroyed.
Transform
GameTransform
Access to position, rotation, and scale. See GameTransform for the full reference.
go.Transform.World = new Transform( Vector3.Zero );
Tags
GameTags
The tag set for this object. Tags are used to filter traces, queries, and component lookups.
go.Tags.Add( "enemy" );
go.Tags.Has( "enemy" ); // true
Components
ComponentList
The list of components on this object. Use the component query methods below or Components.Create<T>() to add new ones.

Component methods

GetComponent<T>

public T GetComponent<T>( bool includeDisabled = false )
Returns the first component of type T on this object, or null if none exists. Only searches enabled components unless includeDisabled is true.
var health = go.GetComponent<HealthComponent>();
if ( health is not null )
    health.TakeDamage( 10 );

GetComponents<T>

public IEnumerable<T> GetComponents<T>( bool includeDisabled = false )
Returns all components of type T on this object.
foreach ( var collider in go.GetComponents<Collider>() )
{
    collider.Enabled = false;
}

GetComponentInChildren<T>

public T GetComponentInChildren<T>( bool includeDisabled = false, bool includeSelf = true )
Returns the first matching component on this object or any descendant. Useful for finding a component anywhere in a hierarchy.
var weapon = go.GetComponentInChildren<WeaponComponent>();

GetComponentsInChildren<T>

public IEnumerable<T> GetComponentsInChildren<T>( bool includeDisabled = false, bool includeSelf = true )
Returns all matching components on this object and all descendants.

GetComponentInParent<T> / GetComponentsInParent<T>

public T GetComponentInParent<T>( bool includeDisabled = false, bool includeSelf = true )
public IEnumerable<T> GetComponentsInParent<T>( bool includeDisabled = false, bool includeSelf = true )
Search upward through the hierarchy rather than downward.
// Find the nearest inventory in parent chain
var inventory = go.GetComponentInParent<InventoryComponent>();

AddComponent<T>

public T AddComponent<T>( bool startEnabled = true ) where T : Component, new()
Adds a new component of type T to this object and returns it. This is a shortcut for Components.Create<T>().
var light = go.AddComponent<PointLight>();
light.Radius = 200f;

GetOrAddComponent<T>

public T GetOrAddComponent<T>( bool startEnabled = true ) where T : Component, new()
Returns an existing component of type T if one exists, otherwise creates and returns a new one.

Lifecycle methods

Destroy

public virtual void Destroy()
Queues the object for destruction at the start of the next frame. All child objects and components are also destroyed. After calling this, IsDestroyed returns true immediately.
go.Destroy();
// go.IsDestroyed == true, but it still exists until next frame
Do not call Destroy inside OnFixedUpdate loops that iterate over the same collection — the object will still be present in the list until the frame ends. Check IsValid() or IsDestroyed before accessing destroyed objects.

Clone

public GameObject Clone()
public GameObject Clone( Transform transform, GameObject parent = null, bool startEnabled = true, string name = null )
public static GameObject Clone( string prefabPath, CloneConfig? config = default )
Creates a deep copy of this GameObject, including all components and child objects. Component property values are copied over. References within the cloned hierarchy are re-wired to point to the clones, not the originals.
// Clone at a position
var copy = prefabGo.Clone( WorldPosition + Vector3.Forward * 100f );

// Clone a prefab by path
var enemy = GameObject.Clone( "prefabs/enemy.prefab", new Transform( spawnPoint ) );

SetParent

public void SetParent( GameObject value, bool keepWorldPosition = true )
Re-parents this object. By default, the world-space transform is preserved so the object does not visually move. Pass keepWorldPosition: false to use the current local transform relative to the new parent instead.
// Attach a pickup to the player's hand without it snapping to origin
pickup.SetParent( handBone, keepWorldPosition: true );

Practical examples

Spawning and destroying an object

public sealed class SpawnManager : Component
{
    [Property] public GameObject EnemyPrefab { get; set; }

    public void SpawnEnemy( Vector3 position )
    {
        var enemy = EnemyPrefab.Clone( position );
        enemy.Name = "Enemy";
    }

    public void KillAllEnemies()
    {
        foreach ( var go in Scene.FindAllWithTag( "enemy" ) )
        {
            go.Destroy();
        }
    }
}

Building a hierarchy at runtime

var root = new GameObject( "Vehicle" );
root.Tags.Add( "vehicle" );

var body = new GameObject( root, true, "Body" );
body.AddComponent<ModelRenderer>();

var wheel = new GameObject( body, true, "Wheel_FL" );
wheel.WorldPosition = root.WorldPosition + new Vector3( 40, 60, 0 );
wheel.AddComponent<ModelRenderer>();

Build docs developers (and LLMs) love