Collider:on_uncollide

Called when a collider or sensor stops colliding with this collider. Default implementation does nothing.

Usage

collider.on_uncollide = function(self, other_component, other_entity, contact)
  -- your code here
end

Arguments

Name Type Description
other_component Collider or Sensor Components this collider was overlapping with.
other_entity Entity Entity no longer being collided, owner of other_component.
contact love.Contact Contact generated by the collision.

As the LOVE documentation recommends:

The lifetimes of Contacts are short. When you receive them in callbacks, they may be destroyed immediately after the callback returns. Cache their values instead of storing Contacts directly.

Examples

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

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

collider.on_collide = function(self, other_component, other_entity, contact)
  print("Bonking against " .. tostring(other_entity));
end

collider.on_uncollide = function(self, other_component, other_entity, contact)
  print("No longer bonking against " .. tostring(other_entity));
end

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