I want to start using physics.set_listener, but once I add the code as shown on the example in the manual, all my objects are still getting their regular collision messages, and nothing is printing from the listener function.
I have a game object with a “main.script” on it which is where my game starts, and this line is in my function init(self)
function, it’s definitely being run because I put a breakpoint on it and it hit.
physics.set_listener(physics_world_listener)
But breakpoints are not being hit on any of the lines below and nothing is being printed. I would expect trigger_event to be hit and I would also expect all the behaviour in my game to break, since according to the manual, objects don’t receive messages once you activate the listener;
local function physics_world_listener(self, event, data)
if event == hash("contact_point_event") then
-- Handle detailed contact point data
pprint("contact_point_event: "..data)
elseif event == hash("collision_event") then
-- Handle general collision data
pprint("collision_event: "..data)
elseif event == hash("trigger_event") then
-- Handle trigger interaction data
pprint("trigger_event: "..data)
elseif event == hash("ray_cast_response") then
-- Handle raycast hit data
pprint("ray_cast_response: "..data)
elseif event == hash("ray_cast_missed") then
-- Handle raycast miss data
pprint("ray_cast_missed: "..data)
end
end
I’m using Defold 1.6.4