Remember that all objects can send and receive messages, so in your case, your player is receiving a collision message in the format that you are describing: “/instance??#collisionobjectTOP”, BUT your other object can also detect the collision and send a message identifying itself, something like (pseudocode):
other object on_message(...)
if message == contact_point
msg(player_url, "I_GOT_YOU", { id = go.get_id() } )
And then your player object would have to listen for these messages:
player object on_message(...)
if message == "I_GOT_YOU"
receive_damage_from(message.other_id)
OR
Another case would be to use only the fragment portion from the sender (sender is an url) so you get the collision that was hit “#collisionobjectTOP” or “#collisionobjectBOTTOM” without taking in consideration who sent it:
player object on_message(...)
if message == contact_point
if sender.fragment == #collisionobjectTOP then
-- receive top damage
else if sender.fragment == #collisionobjectBOTTOM then
-- receive bottom damage
end
if message_id == hash("contact_point_response") then -- check if we received a contact point message
if message.group == hash("foot_girl") then -- check that the object is something we consider geometry
handle_geometry_contact(self, message.normal, message.distance)
end
end
in my dino script i put this inside message function:
if message_id == hash("contact_point_response") then
if message.group == hash("hero") then
pprint("+++++++ begin test")
pprint("footgirl as url: " .. msg.url("footgirl"))
pprint("message sender: " .. sender)
pprint("message id: " .. message_id)
if sender == msg.url("footgirl") then -- check edga hint
print('OK to URL')
end
if message.group == hash("footgirl") then -- check dajev hint
print('OK to group')
end
pprint(" === start message info")
pprint(message)
pprint(" === end message info")
pprint("+++++++ end test")
end
end
and this is my console response:
DEBUG:SCRIPT: +++++++ begin test
DEBUG:SCRIPT: footgirl as url: [main:/footgirl]
DEBUG:SCRIPT: message sender: [main:/instance1#collisionobject]
DEBUG:SCRIPT: message id: [contact_point_response]
DEBUG:SCRIPT: === start message info
DEBUG:SCRIPT:
{
normal = vmath.vector3(0, -1, 0),
position = vmath.vector3(220.70994567871, 70.166679382324, 0),
other_position = vmath.vector3(237.7099609375, 120.5647354126, 0.30000001192093),
relative_velocity = vmath.vector3(0, 0, 0),
other_id = hash: [/hero],
other_mass = 0,
group = hash: [hero],
applied_impulse = 0,
distance = -0.66667795181274,
life_time = 0,
mass = 0,
}
DEBUG:SCRIPT: === end message info
DEBUG:SCRIPT: +++++++ end test
You need to change the group of the hero collision object foot_girl to foot_girl, if you want to check different collisions objects on the same game object, they must belong to different groups, else all collisions will be checked under the same group
Yes @Edgaronfo, thats right, but at least then you can check for a specific collision, if he wants to still use that area under hero, he can always place another collision object int the same area and call it hero still.
In this specific case, your dino is checking for the hero, and NOT the hero for the dino, so the collisions that will be sent as sender will be you dino’s, that is why you receive “collisionobject” as your sender.
So if you want to know if you hero’s feet got bitten, you have to put code in your hero’s script, then you will be able to receive the hero’s collisions as senders.
Try this in your hero.script:
if message_id == hash("contact_point_response") then
if message.group == hash("dino") then
print("message sender: " .. sender)
and your result will be something like: DEBUG:SCRIPT: message sender: [main:/hero#foot_girl]
I was trying “teach” to dino when he should die… but defolt dont tell to receiver the id of other collision object. basically a GO/script has access only to own object collisions.
Now this is my information path:
1 - in girl i check if sensor foot make contact with dino…
2 - so i send a message to dino with command “die”
3 - the dino receive the command and send a return message to girl telling his coordinates Y and starts his die animation
4 - the girl receives the message with coordinate and start to jump from dino’s head.