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 xproject2013 · Feb 19, 2014 at 11:29 AM · c#collisionboxcolliderevent-handling

Check different collisions

Hi everybody, I want to know if is possible split the collisions check made by a collider set as "is Trigger" and other separate collider not set as "isTrigger".

To explain better the problem look at the image: I have my gameobject (1) L shape and I have to check his collisions with other objects.

Inside it has two box collider set as "is Trigger" (2) triggered and a wrapper surrounding collider (3) not set to "is Trigger" but i need it to simplify the drag process of the object.

It's possible in the function OnTriggerEnter, OnTriggerStay and OnTriggerExit exclude the wrapper collider?

Thanks in advance!alt text

collisions.jpg (34.1 kB)
Comment
Add comment · Show 5
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 mattyman174 · Feb 19, 2014 at 11:37 AM 0
Share

All you need is a Reference to the Trigger you dont want to detect, whenever those Functions detect that a collision is made with that Trigger, just ignore it since you dont want anything to happen with that particular Trigger.

avatar image xproject2013 · Feb 19, 2014 at 01:52 PM 0
Share

Could you post some code example how to do this?

avatar image RudyTheDev · Feb 19, 2014 at 03:39 PM 0
Share

If I understand the problem correctly, you probably just want to put collider GameObjects in different layers (and set the Physics Project settings to not collide your wrapper collider with whatever). In your input raycasting, only specify those layers you want to raycast against.

Or you can just RaycastAll and iterate through hits to find the one you need.

avatar image xproject2013 · Feb 25, 2014 at 08:58 AM 0
Share

Sorry for the delay in response, basically I have this GameObject that is instantiated via script, and then I can't put colliders on different layers as they are already contained in it. I could keep the collider that should not do collisions always in the last place of the other colliders in the inspector and create a script that excludes collisions from the last collider (i can use GetComponents) but I don't know how to set this script and if it's possible, could you help me?

avatar image RudyTheDev · Feb 25, 2014 at 10:11 AM 0
Share

Have you tried Edit->Project Settings->Physics->Layer Collision $$anonymous$$atrix? You can set up which layers are supposed to collide with which other layers. And you can easily change which layer the game object is on with gameObject.layer.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by exp626stitch · Dec 16, 2020 at 06:50 PM

@xproject2013 Try using 3 objects,

  1. your gameobject (no collider)

  2. checking for collisions (2 colliders)

  3. dragging (trigger collider?)

All paired to a master gameobject. When you want to do something with those collisions, acsess the children, and do what you want to do with them. (Might want to set main gameobjects position to the childs position, using)

 public void Update() {
 transform.position = child.transform.position;
 //Disclaimer: this might not work, I have not tested it
 }
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

21 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

Related Questions

How to access variables from another script on collision ? 1 Answer

Distribute terrain in zones 3 Answers

My marble (Player/Gameobject) goes through the "play board" (gameobject). Why? 1 Answer

Multiple Cars not working 1 Answer

Know if there is Collisions on my boxCollider 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