hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
34 lines (18 loc) • 1.03 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [Entity](./server.entity.md) > [despawn](./server.entity.despawn.md)
## Entity.despawn() method
Despawns the entity and all children from the world.
Use for: removing entities from the world. Do NOT use for: temporary hiding; consider visibility or animations instead.
**Signature:**
```typescript
despawn(): void;
```
**Returns:**
void
## Remarks
\*\*Cascading:\*\* Recursively despawns all child entities first (depth-first).
\*\*Controller:\*\* Calls `controller.detach()` then `controller.despawn()` if attached.
\*\*Cleanup:\*\* Automatically unregisters attached audios, despawns attached particle emitters, and unloads attached scene UIs from their respective managers.
\*\*Simulation:\*\* Removes from physics simulation.
\*\*Side effects:\*\* Emits `EntityEvent.DESPAWN` and unregisters from world managers.
\*\*Category:\*\* Entities