Optionaloptions: DetectionPluginOptions<G>const ecs = ECSpresso.create()
.withPlugin(createTransformPlugin())
.withPlugin(createCollisionPlugin({ layers }))
.withPlugin(createSpatialIndexPlugin())
.withPlugin(createDetectionPlugin())
.build();
// Read nearest detected entity:
const detected = ecs.getComponent(turretId, 'detectedEntities');
const nearest = detected?.entities[0];
Create a detection plugin for ECSpresso.
Populates
detectedEntitieseach frame with nearby entities matching the detector's layer filter, sorted by distance (nearest first). PublishesdetectionGained/detectionLostevents on transitions.Requires the spatial-index and transform plugins to be installed.