Despawning Entities
To despawn an entity from the world, it is as simple as calling engine.despawn(id)
.
To retrieve the entity id for despawning, the id can be queried for by using the EntityId
component.
ts
import { EntityId, Query, Component } from '@vaguevoid/fiasco'
type Car = Component
function system(cars: Query<[EntityId, Car]>) {
// despawn the first car available
for (const [entity] of cars.take(1)) {
engine.despawn(entity.id)
}
}