Entity:remove_component

Removes a component from this entity.

Removed components cannot be added back or transfered to other entities, as add_component always instantiates a new component.

Usage

entity:remove_component(component)

Arguments

Name Type Description
component Component The component to remove.

Examples

local Health = Class("Health", crystal.Component);
local ecs = crystal.ECS:new();

local entity = ecs:spawn(crystal.Entity);
local health = entity:add_component("Health");
entity:remove_component(health);
assert(entity:component("Health") == nil);

This site uses Just the Docs, a documentation theme for Jekyll.