Why is my collision response message not received?

Hey! I have a dynamic collisionobject that collides with a static object. I can’t catch the collision message.
This code just does nothing:

function on_message(self, message_id, message, sender)
	if message_id == hash("collision_response") then
		go.delete(id)
		sound.stop("#bombwhistle")
		check = 0
		print("collision")
	end
end

Are you sure the two objects are colliding? Do they have matching collision groups and masks? Enable physics debug to see what’s going on:

PS When you share code make sure to surround it with three back-ticks like this

```
Your code here
```

They are a bomb and a house. They collide, the bomb bounces on the house. Regarding the groups and masks I haven’t done anything.

Is the script part of the same game object as the collision object?

1 Like

Yes, I just can’t get a collision response. I set the group and mask, as well. I am trying to make it as simpla, as possible, but I can’t make this code work:

function on_message(self, message_id, message, sender)
	if message_id == hash("collision_response") then 
		print("Collision")
	end
end

It just does nothing.

Ahhh… you were right. It wasn’t part of the same gameobject!

2 Likes

Are they in they both instanced under the same collection? I’ve experienced something like this a while ago, and I found that if you spawn the two using factories in the same collection, it solves the problem.