Create a flockingAgent component with sensible defaults.
Entities must also have a circleCollider with radius >= perceptionRadius for the spatial index to find them as neighbors.
circleCollider
Optional
Partial overrides for flocking agent fields
Component object suitable for spreading into spawn()
ecs.spawn({ ...createFlockingAgent({ perceptionRadius: 80, maxSpeed: 150 }), ...createRigidBody('dynamic', { mass: 1, drag: 1, gravityScale: 0 }), ...createCircleCollider(80), ...createGraphicsComponents(boidGraphics, { x: 100, y: 200 }),}); Copy
ecs.spawn({ ...createFlockingAgent({ perceptionRadius: 80, maxSpeed: 150 }), ...createRigidBody('dynamic', { mass: 1, drag: 1, gravityScale: 0 }), ...createCircleCollider(80), ...createGraphicsComponents(boidGraphics, { x: 100, y: 200 }),});
Create a flockingAgent component with sensible defaults.
Entities must also have a
circleColliderwith radius >= perceptionRadius for the spatial index to find them as neighbors.