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 sporkflips · Oct 13, 2016 at 07:00 AM · collider3dcolliders

Can I make a hole in a mesh collider?

I'm building a cave system for my game and there are separate cave 'houses' that go inside it but I want them to protrude out through it like you're walking into a dug out area in the wall. I'm using a script to set the render queue that makes it so you can't see the cave walls that come through but is there a way to make it so you can pass through part of a collider while the rest of it still works?

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

Answer by Sergio7888 · Oct 13, 2016 at 04:56 PM

You cant make a hole in a collider, you can use multiple child objects with small colliders, or depending the case change the Collision Matrix.

Comment
Add comment · Show 2 · 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 sporkflips · Oct 13, 2016 at 10:04 PM 0
Share

Okay, I guess I'll just change the mesh since it's too complicated to use a series of built in colliders for. The Collision $$anonymous$$atrix seems interesting for other applications though, I hadn't read about that before. Thanks.

avatar image Namey5 · Oct 15, 2016 at 06:50 AM 0
Share

Technically speaking, you can make a hole in a mesh collider by regenerating the shared mesh with certain modifications. However, it would take a lot of work and wouldn't necessarily be practical.

avatar image
1

Answer by OusedGames · Oct 15, 2016 at 04:41 PM

I do not know if I undestand your question but I will try to help:

  • When player collides with the wall

  • You Disable the wall collider and when the player goes through, re enable it again;


void OnColisionEnter(Collision col) {

     if (col.gameObject.tag == "Wall") {
         col.gameObject.GetComponent<MeshCollider>().enabled = false;
     }
 }
  • Then use a Coroutine or float var on update to reactivate the collider;


Hope it Works @sporkflips

Comment
Add comment · Show 2 · 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 sporkflips · Oct 15, 2016 at 06:24 PM 0
Share

I guess this could work so that if the player is within a certain area the mesh collider would be disabled, but I suppose it was probably easier to just fix the mesh so that it wouldn't be in the way to begin with. I would think this would also only work if there are no other game objects that would fall through the mesh while it's disabled. This is interesting to keep in $$anonymous$$d though, could it be applied to a Terrain object?

avatar image Bonfire-Boy · Oct 15, 2016 at 07:26 PM 0
Share

Yes, it could be problematic if it's important for the collider to continue to work with other objects. A similar approach, which might get around this problem, would be to temporarily change the layer of the player gameobject to one which doesn't interact with the layer of the collider (as defined in the physics settings). This might also be problematic of course, but differently so.

Seems to me that the other approach (ie not having a collider in the place where you don't want collisions) is likely to be better in most situations.

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

7 People are following this question.

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

Related Questions

My 3D collider is not detecting colissions. 1 Answer

how to Stop Enemys from clipping into eachother? 0 Answers

3D game: Pickups don't disappear when player touches them. 4 Answers

3D Colliders isue 1 Answer

Reposition objects during character customization 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