Sensor:activations

Returns all components currently activating this sensor.

Usage

sensor:activations()

Returns

Name Type Description
activations table A table where every key is a Fixture or Sensor, and the values are their owning entities.

Examples

local ecs = crystal.ECS:new();
local physics_system = ecs:add_system(crystal.PhysicsSystem);

local hero = ecs:spawn(crystal.Entity);
hero:add_component(crystal.Body);
hero:add_component(crystal.Collider, love.physics.newCircleShape(4));
hero:set_categories("characters");
hero:enable_collision_with("level", "triggers");

local pressure_plate = ecs:spawn(crystal.Entity);
pressure_plate:add_component(crystal.Body);
pressure_plate:add_component(crystal.Sensor, love.physics.newCircleShape(8));
pressure_plate:set_categories("triggers");
pressure_plate:enable_activation_by("characters");

ecs:update();
physics_system:simulate_physics(0.01);

local component, entity = next(hero:activations());
assert(entity == hero);
assert(component == hero:component(crystal.Collider));

This site uses Just the Docs, a documentation theme for Jekyll.