How can I pick a GameObject on which clicked?

I have two GameObject in collection. I need to get the id of the GameObject on which clicked.
The GUI has a function gui.get_node and gui.pick_node. How can I pick a GameObject on which clicked?

File: test_input.script

function init(self)
msg.post(".", “acquire_input_focus”)
end

function on_input(self, action_id, action)
if action_id == hash(“touch”) then
print(go.get_id())
end
end

There is a thread on the forum, concerning that issue. You have to manually check if the click is within the boundries of your object. I do this in a small game I’m developing now, and it works ok. :blush:

Edit:
This post -> Click on game object

Edit2:
If I understand you correctly, you want to check if you clicked a GameObject, and do something to it? Take my advise with a small grain of salt, since I’m new to this, but I would either let each GameObject check if they where clicked, or put a check in a central script. Let that check loop through the relevant GameObjectsIDs, and check their positions. There are probably lots of ways to do this more efficient, but just try something, to see if it work, then optimize later. :slight_smile:

1 Like

I used binding to a coordinate system but I thinking there is still some way. :slight_smile: Thank you so much.