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 oliver-jones · Aug 31, 2011 at 12:14 PM · collisionphysicslayersignore

Physics.IgnoreLayerCollision - Help

Hello,

I have a cube on my game with a box collider, I also have an enemy with a capsule collider - I would like my enemy to walk through the box by avoiding any collisions.

I have given my cube a layer called "EnemyIgnore" (layer 8).

In my Enemy AI script, I have put in the Awake Function:

 Physics.IgnoreLayerCollision(8,8, true);

But this doesn't seem to work, what am I doing wrong?

Also, I don't want to use any triggers ... I just want this to be a one off 'no collision' detection, thus causing my enemy to walk through the cube, and vise verser.

Thanks

Comment
Add comment · Show 1
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 eklumt · Jan 18, 2014 at 12:46 AM 0
Share

This isn't an answer, but thank goodness someone worded this script with just the 8,8,true, as numerical values or I would never have gotten past the "layer doesnt exist" issue. I couldn't for the life of me figure out how to make it read the layers when I typed in Layer8,Layer9. Now I feel dumb.

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by Owen-Reynolds · Aug 31, 2011 at 02:04 PM

What layer is your enemy on? So far, you've said that things on EnemyIgnore won't hit themselves (other things on layer 8.)

Seems like you need an Enemy layer 9, and IgnoreCollide(8,9)

Also, you can go to Edit->physics and check the matrix there, if you aren't totally confident the code line is getting the job done.

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

Answer by Molix · Aug 31, 2011 at 02:03 PM

You have set it so all objects in the EnemyIgnore layer will ignore collisions with all other objects in the EnemyIgnore layer, but from your description that does not seem to be what you want. For one, your enemy is probably in a different layer (e.g. an Enemy layer), and for another, it is not really a one-off in that all objects on those layers will be affected.

So either check the layer of your enemy, or, if it is really just a 'one off', then you can just use Physics.IgnoreCollision to specify the two object's colliders specifically.

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 Waz · Aug 31, 2011 at 06:37 PM 0
Share

Physics.IgnoeCollisions has the annoying problem that when objects are disabled the setting is lost. Physics layer-based collision is way easier to manage if you have, for example, distant objects being disabled for performance reasons.

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

6 People are following this question.

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

Related Questions

Enable / Disable Layer Collision Matrix thru Script 1 Answer

Physics Collision Layer Programmatically. 0 Answers

revert Physics.IgnoreCollision 2 Answers

How do you enable the layer based collision matrix? 1 Answer

Collision stuck issue 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