• 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
Question by bpears · Jan 27, 2013 at 04:34 AM · javascriptcollider

How to ignore specific collider, non-raycast?

Possible? I can't just disable the collider in my case, and cannot use a raycast approach.

Edit: More detail- I am trying to achieve a player, that is non playable, to be able to pass through a specific collider, while the player cannot. However now I am thinking of a different approach, and maybe just transform position of the NPC's mesh, and just repawning the collider and other stuff onto the otherside, once mesh gets there. So it would appear, that they had gone through, but really just repawned. It would be a little complicated because of moving the mesh, yet respawning also. So maybe make a ragdoll that animates and transforms position instead. IDK, I'm just throwing ideas out.

Comment

People who like this

0 Show 6
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 sparkzbarca · Jan 27, 2013 at 04:37 AM 1
Share

whats raycast have to do with it?

Are you trying to disable the object for the purposes of collision detection. Or perhaps for the purposes of collision detection against a specific second collider.

Often its best to say not what you need in coding terms but in non technical terms. Alot of times if you need something unique you really dont. You just havent thought of the ideal solution to your problem.

Perhaps you could say I need to be able to pass through walls temporarily or whatever your problem is in a non technical manner.

avatar image AlucardJay · Jan 27, 2013 at 04:46 AM 1
Share

I think non-raycast was specified to say 'I cannot use layermask', and I can see where this situation of only allowing certain collision events could be applied hence the question.

Imagine the player character is a ghost, it can pass through walls but if it hits a lamp or flowerpot then use normal collision.

The question could use a much better description, but it is a valid and good question (I am also interested having written my own 'ghost' game).

As soon as I typed that I realized that what you need and are looking for is the Physics Manager , in which case you can absolutely use layers : http://docs.unity3d.com/Documentation/Components/class-PhysicsManager.html

I have only used this matrix for raycasts, but imagine it does the same for all physics as it suggests. Do some tests and let us know =]

avatar image sparkzbarca · Jan 27, 2013 at 04:48 AM 1
Share

yea i mean i can guess what he might want but a better phrasing and description is needed really

avatar image Manco Capac · Jan 27, 2013 at 03:27 PM 1
Share

There is sth: Physics.IgnoreCollision I never used it, so I don't really know...

link text

avatar image Rajeesh_AR · Dec 11, 2015 at 01:21 PM 2
Share

@bpears .........

Unity provides the option to avoid the collission of specific colliders. I will tell the process in your case: put NPC'c layer as "npc" and the block layer as "block" (or whatever except default). Now go to Edit> Project Settings > Physics ........ There you can see all the layer names in matrix form and all checked. Uncheck the one which intersect on "block" row & "npc" column or vice versa. Now these colliders will not detect each other...

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Wolfrik_Creations · Dec 10, 2015 at 05:19 PM

Try putting something like this on your NPC

 function OnCollisionEnter(col:Collision) {
       if(col.gameObject.tag=="NoCollision") {
             col.GetComponent.<Collider>().enabled=false;
       }
 }
 
 function OnCollisionExit(col:Collision) {
       if(col.gameObject.tag=="NoCollision") {
             col.GetComponent.<Collider>().enabled=true;
       }
 }

but this might not work if your player walked at the same time as the NPC through the wall.

All else fails you could try not putting a collision on your NPC if that's an option.

Comment
Rad-Coders

People who like this

1 Show 0 · 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

Answer by dhore · Dec 11, 2015 at 01:02 PM

Use the Physics.IgnoreCollision function to tell the physics engine to completely ignore all collisions between 2 specific gameobjects.

Comment
Raresh

People who like this

1 Show 0 · 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

Answer by Rad-Coders · Dec 10, 2015 at 10:48 PM

Add a new layer for all the colliders you don't want your NPC to collide with and a layer on your NPC. Then just edit the Layer Collision Matrix (Under Edit>ProjectSettings>Physics) so that they don't collide.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

Multiple Cars not working 1 Answer

Collider Problem 2 Answers

how to morph character on collision enter with gameobject 1 Answer

Trigger to make another trigger to appear? 2 Answers

How to destroy Terrain grass using colliders? 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