Self group in collision/trigger message? [SOLVED] -> own_group

Let’s create a use case: we have a mob with multiple collision objects and if the player collides with each I want to perform different tasks. Is it true, that we don’t have any information about which collision group of the mob was triggered? Is it possible to just expose somehow group of its object? One workaround I see is to create two different collision objects for player and each of them would collide with different trigger of the Mob, so we could check for other’s group. But otherwise, it’s not possible to check for self group.

Isn’t there a message.other_group?

Oo. There is. Indeed. But it points to the same group as message.group :thinking:
After printing:

print("COL_group", message.group)
print("COL_other_group", message.other_group)

I see:

DEBUG:SCRIPT: COL_group hash: [hero_body]
DEBUG:SCRIPT: COL_other_group hash: [hero_body]

And in the documentation there is only group message mentioned:
group

the collision group of the other collision object (hash)

What message are you listening to? Both collision_response and contact_point_response have fields for own group and other group. Are you sure the groups are defined correctly on your collision objects?

Aaa, I was following this page.

I am listening to the collision_response.
And indeed, the message.own_group is what I’m looking for. So, thank you very much for providing this :wink:

So the remaining question is - what is message.group for? As it’s the same as message.other_group? Could those inaccuracies be corrected on those pages?

1 Like

The only message I recall that has a field named just group is ray_cast_response, are you using ray casts? If not, where are you seeing message.group?

I’m using collision_response and the message received is like this:

DEBUG:SCRIPT: 
{ --[[000000002C0C2600]]
  other_group = hash: [hero_body],
  other_position = vmath.vector3(4, 5.9305553436279, 0.99000000953674),
  own_group = hash: [mob_fov],
  group = hash: [hero_body],
  other_id = hash: [/hero]
}

The code for this:

	if message_id == hash("collision_response") then
		pprint(message)
	end

“mob_fov” is the group of collision object of the mob, which also has a mask “hero_body”
“hero_body” is the group of collision object of the player, which also has a mask “mob_fov”

As you can see “hero_body” group is in the message.group and message.other_group

1 Like

Woah, it looks like there is a discrepancy between the docs and the actual message for collision_response then!

2 Likes

Hopefully this side discovery is helpful at least :smiley: Anyway, thanks again with finding own_group :wink:

message.group is deprecated and there for backwards compatibility reasons. Own_group and other_group should be used.

1 Like