• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TommyB · Apr 06, 2014 at 09:22 PM · iostouch

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TommyB · Apr 27, 2014 at 08:48 PM 0
Share

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 minor differences/mappings must be

avatar image
0

Answer by cjgstudio · Apr 06, 2014 at 11:14 PM

I agree with taras, use getbuttondown. That way you can use it on pc also for testing.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image timdan · Oct 26, 2014 at 08:56 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

OnMouseDown works fine for iOS 2 Answers

Unity double tap explanation 0 Answers

Unity iOS Swipe not working 1 Answer

Having an issue with getting my touch controls working 0 Answers

Keep camera horizontal with RotateAround 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges