Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
4
Question by isteffy · Sep 09, 2015 at 02:55 PM · layersclickonmousedownz-axisonmouseup

How to: Click top Object of 2 overlapping objects (2D)

I want an easy way to click the top gameObject of two overlapping gameObjects -2D only please- Example: Two clickable 2D objects overlap, gameObject A (top) and gameObject B (bottom). gameObject A has a higher z-axis and is visibly on top, but only gameObject B is clickable. Object A is higher but only B ic clickable. B was there first and is the Background of my scene.

I've seen a similar question here, http://answers.unity3d.com/questions/598492/how-do-you-set-an-order-for-2d-colliders-that-over.html but I do not want a huge work-around involving Raycast/Linecast.

I appreciate your work-arounds, but Clicking a gameobject that is on top, is the most basic concept in computer gaming and I have hard believing that Unity does not have a straight forward answer to this.

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
1

Answer by DientesDeCheto · Jan 07, 2016 at 06:34 PM

Are you shure, that your Objects have different z-axis when game is running? (Maybe z-axis is overwritten) Do you use 2d BoxCollider? Try with 3d BoxCollider! When Object B's BoxCollider is setted off, does Object A's BoxCollider trigger?

I have several GameObjects flying through the Screen, each of them need to be adjusted on z-axis automatically depending on which was clicked, and without any problems I have following Components with different configs: -Transform-Position: Z-Axis = -1, -1.1, -1.2, etc and -2 to bring those to the front (top) -BoxCollider (not BoxCollider 2D!!!) -RigidBody

Thats all I have attached. I remember I had some issue with BoxCollider 2D, so I decided to use BoxCollider. I hope it was usefull. Good Luck @isteffy

Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Text popup onMouseDown 2 Answers

Why my OnMouseDown is lost?!!! 0 Answers

Can't click gameobject when over another trigger? 1 Answer

OnMouseOver Problem 3 Answers

Raycast examples needed - alternative to OnMouseDown, OnMouseUp 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