Touch not working (SOLVED)

#1
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!)

0 Likes

#2

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

#3

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

0 Likes

#4

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

0 Likes

#5

Tested on android and in defold simulator

1 Like

#6

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

#7

Capture

In the script (it acquires input)

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

0 Likes

#8

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

0 Likes

#9

Capture

0 Likes

#10

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

0 Likes

#11

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

1 Like

#12

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?)

0 Likes

#13

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

0 Likes

#14

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