I´m having trouble understanding the messages i get on a collision. I need to check if the other object is above or below the one that receives a collision. I have tried many variations on the theme of
go.get_position(other_id)
but I can’t figure it out. If anyone could help me out I’d really appreciate that.
Are you saying that go.get_position(message.other_id) isn’t working? It should give you the position of the object you collided with. You could also look at the message.normal from a contact_point_response since it “points from the other object towards the current object”.
No problem. I had the same problem some days ago. There are two solution for you…
you can use the option that @britzl said, something like:
in destination
function on_message(self, message_id, message, sender)
if message_id == hash("my_action") then
local p = go.get_position(message.other_id)
....
end
end
or i can send the position by parameter at the origin, something like…
in Script one (the origin of messenge)
-- some place in the origin script
local p = go.get_position()
msg.post("main:/destinationGO#script","do_something",{position = p})
-- some place in on_message function in the script destination
function on_message(self, message_id, message, sender)
if message_id == hash("do_something") then
-- to see all parameters try to use pprint(message)
pprint(message.position)
end
end