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
1
Question by BobbyBoy222 · Dec 30, 2017 at 04:54 AM · collider2dtriggerscollisions

Colliders overlapping with trigger colliders

I have a script that reacts to the mouse going over certain trigger colliders (all 2D), but when I have a regular collider overlap with the triggers, the overlapping area no longer responds to the mouse. Is there anyway to resolve this? I'm trying to avoid putting the under the same object.

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
Best Answer

Answer by sparkzbarca · Dec 30, 2017 at 07:25 AM

you can use layers and raycasts that ignore layers.

The issue is the regular collider is intercepting the raycast as it were.

raycastall might work as a kind of hacky thing.

raycast vs raycastall, raycast returns the FIRST object hit, raycastall penetrates and returns all objects.

Once you realize your issue is you've basically covered up your trigger collider in a blanket you realize you just need to make sure you fix that.

In this case you can either assign trigger colliders to Trigger layer or Mouse layer or whatever (name is arbitrary)and raycast only on triggers or you can assign regular collider to Regular Layer or whatever and exclude that layer from the cast, which is really a cast to all but.

Basically the cast will still hit the first trigger but then unity will do a "is this object's layer such that it counts as an object this ray can hit?" if the answer is no then it ignores it and goes on until it hits one that counts.

This can have many uses, for example a raycast that ONLY hits terrain can be useful for a lot of reasons or a raycast that ONLY hits say the player. If all your interested is a certain individual or group of objects counting as valid targets, placing all those in a layer and only casting a ray against that layer is the way to do that.

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 BobbyBoy222 · Dec 30, 2017 at 02:32 PM 0
Share

I didn't mention that I've been using On$$anonymous$$ouseOver for this, would I just have to use a constant raycast in place of it?

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

74 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 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 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 avatar image avatar image

Related Questions

problem solving ghost vertices with trigger and collision colliders 0 Answers

OnTriggerEnter being called event though there is no collision? 0 Answers

Problem with the collider trigger,How to use colliders with trigger? 2 Answers

How to check witch colliders are within trigger 0 Answers

2D - Two objects, each having two trigger colliders - interacting 0 Answers


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