- Home /
Touch input firing twice on ios
I recently made a simple game for windows phone that has a menu scene that you can touch anywhere to activate the game and subsequently loads my game scene. In the game scene you can then tap to manipulate an object. When I run this on a windows phone or in Unity it works correctly. I've since ported my game to ios, again the interactions work perfectly in Unity itself. However on an actual device, if I touch the menu, it loads the gameScene, but it also seems to fire off a touch event straight away and moves the player object which is incorrect.
I'm currently using
if (Input.GetButtonUp ("Fire1"))
on the menu screen and the game scene to handle the input.Should I change this to one of the "touches" methods?
Answer by tarasfromlviv · Apr 06, 2014 at 10:01 PM
Why don't you just use Input.GetMouseButtonDown(0)
to handle the touch? It works on desktop as well as with touch screens.
I've accepted this, but for the record Input.GetButtonUp ("Fire1") behaves exactly the same and also works on a pc (As per @No1Survivalist comment below) however it seems to fire multiple times on mobile devices so I'm not quite sure what the $$anonymous$$or differences/mappings must be
Answer by corriedotdev · Apr 06, 2014 at 11:14 PM
I agree with taras, use getbuttondown. That way you can use it on pc also for testing.
As far as I can tell GetButtonDown only works for the whole screen with touch. How do I have two touch buttons with GetButtonDown?
Your answer
Follow this Question
Related Questions
Keep camera horizontal with RotateAround 1 Answer
How to draw a line with touch? 1 Answer
Touch for iOS, action occurs on release -2 Answers
OnMouseDown works fine for iOS 2 Answers
Unity double tap explanation -1 Answers