Getting other_id from a collision

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.

Hey @88.josh,

What you are asking seems to be a trend, look at these two links to see more on that, here:
include-more-one-value-in-collision-array-message and here: how-to-check-the-objectcollision-that-send-message-solved

Hope it helps you getting on your way

1 Like

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”.

1 Like

hey @88.josh good morning.

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

some days ago i discover a important concept about defold messages. i registered all in this post. considered take some minutes to read it. maybe helps you too.

See you man. Have a nice day!

3 Likes