Strata - v1.4.10
    Preparing search index...

    Function removeComponent

    • Removes a component from an existing entity.

      Dynamically removes a component at runtime. The entity will no longer match queries that require this component. Uses Miniplex's reactive system.

      Type Parameters

      • T extends BaseEntity
      • K extends string | number | symbol

      Parameters

      • world: StrataWorld<T>

        The Strata world.

      • entity: T

        The entity to modify.

      • component: K

        The component key to remove.

      Returns void

      const entity = world.spawn({
      position: { x: 0, y: 0, z: 0 },
      health: 100
      });

      // Remove health component (entity is now invulnerable)
      removeComponent(world, entity, 'health');

      // Entity no longer matches 'health' queries
      for (const e of world.query('health')) {
      // entity is NOT included
      }