Entities
An Entity is the basic building block of your PlayCanvas scene (Entity
).
Key characteristics
- An Entity can have zero or more components.
- Entities can be parented to form a hierarchy (
addChild
,removeChild
). - Entities can be enabled or disabled (
enabled
).
tip
Keep Entities lightweight — avoid adding unnecessary components.
Creating an Entity in code
const entity = new pc.Entity("MyEntity");
app.root.addChild(entity);
Enabling / Disabling Entities
entity.enabled = false; // Disables the Entity and all its components
tip
Disable Entities when not in use to reduce processing and improve performance.
Lifecycle
- Creation —
Entity constructor
. - Parenting —
addChild
/removeChild
. - Destruction —
destroy
.
tip
When an Entity is no longer needed, call destroy
to free resources and detach it from the hierarchy.