Touch not working (SOLVED)

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

function final(self)
	msg.post(".", "release_input_focus")
end

function on_input(self, action_id, action)
	if action_id == hash("touch") then
		print("Touch!")
		msg.post("/Controller#GameProxy", "load")
	end
end

Not working touch event (not even printing Touch!)

Hi!

I could be due to a number of different issues.

  • Is the script attached to a gameobject or GUI inside the running collection?
  • Is the “touch” action added inside your game.input_binding file? To what input triggers?
1 Like

Yes, it is attached, and touch is a bind for multitouch in input_binding

Are you testing on a mobile device? Multi touch is currently only supported on iOS and Android native applications with Defold.

Tested on android and in defold simulator

1 Like

Is the script part of a collection proxy? If so:

”If you have objects in your loaded collection that require input actions, you need to make sure that the game object that contains the collection proxy acquires input. When the game object receives input messages these are propagated to the components of that object, i.e. the collection proxies. The input actions are sent via the proxy into the loaded collection”

3 Likes

Capture

In the script (it acquires input)

function init(self)
msg.post(".", “acquire_input_focus”)
msg.post("/Controller#MenuProxy", “load”)
end

Can you share an image of your input bindings as well?

Capture

Could you please share your project in PM? I can check what’s wrong and help you to solve the issue.

My guess is that you haven’t set a binding for left mouse button. This will on mobile enable single touch events.

1 Like

You mean, for single touch events I need to enable mouse left button? (If my game doesn’t need multitouch, I need to use just mouse left button?)

Exactly! It is mentioned in the input manual but it’s a thing many miss. I will clarify this.

I have updated the Input manual in a few places to really try to highlight single vs multi touch and how left mouse also sets up touch triggers.

2 Likes