Getting other_id from a collision

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