Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 InfiniBuzz · Jun 09, 2013 at 11:21 AM · camerauitouchcamera controls

Can I limit touch input for camera movement to non-ui areas?

Hi there

First I have two cameras. One for the UI/HUD and the MainCamera both on different layers. I can control the camera by touch input - pinch to zoom and swipe to orbit. Now when I use the 2D UI elements/controls the camera also moves around because I am using the Input.GetTouch() method for the camera script. What I try to do is limit the touch input for the camera movement to "non-UI" areas so that the UI is in front and has priority.

I read about CullingMask but I don't know how to use this to solve my problem. Is there a way to "filter" the colliders of the UI? I always think this can not be that difficult, however I'm stuck.

Thank you for any help!

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

1 Reply

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

Answer by Fattie · Jun 09, 2013 at 11:25 AM

Everyone hates this problem! There is no really good solution.

If Unity worked the "other" way, it would be just as bad.

I feel the simplest approach is:

in your ORBIT script. simply check if you are indeed hitting one of the colliders of the UI. if so, ignore it and do nothing.

if your UI is confined to a specific simple area (say "the top 1/4 of the screen") ... just make one collider called "UI exclusion zone". and again in your game controls, just check if you are hitting that and if so, just ignore that touch.

Hope it helps

PS - I notice you are a new user. Be sure to "Tick" any useful answers please. You get points, and can this ask more questions in the future

Comment
Add comment · Show 3 · 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 InfiniBuzz · Jun 09, 2013 at 12:32 PM 0
Share

Thanks for the answer. Would I achieve this using raycasts? Or what method did you think of?

Yes, I'll do that!

avatar image InfiniBuzz · Jun 09, 2013 at 01:13 PM 1
Share

It's working now as it should! fyi I use ScreenPointToRay on the UI camera and mask the Raycast with the ui layer. Simple as that :) Please let me know if this is not a proper method in this case. Thank you for getting my work rolling again!

avatar image Fattie · Jun 09, 2013 at 01:44 PM 0
Share

exactly, with a raycast

how you described it in your second comment is exactly what everyone does. Rock on !

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.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

canvas screen space camera rotation issue 0 Answers

rotate camera in android unity 1 Answer

Camera touch control script 1 Answer

Galak Z like UI element 0 Answers

Mobile touch input conflicts 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges