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 Bezzy · Oct 26, 2011 at 10:45 PM · physicslayersmatrixlayermask

Getting physics ignorance layers from script

I'm putting together an extension script to do more robust physics at high speed (hope to make it available if it works - should provide something more robust than Don'tFallThroughThings). I'm trying to make it easy for anyone to use (but also expose more advanced tools for those who need it).

Briefly: it's based on SphereCasts (just those for now - extending out based on collider type should be fairly easy). Sphere casts have a layer inclusion option.

I wanted to make sure that in its simplest form, it'd use the same layer as the rigidbody it's being applied to and then establish what layers it should ignore based on the Physics Manager Matrix (so that ignores all layers that it's been set up to ignore). At the moment I have to declare this manually.

Is there any way to pass a Layer number into Physics, and have a layer mask return which tells you which layers are ignored/noticed?

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
0

Answer by roamcel · Oct 27, 2011 at 11:28 AM

I believe there's only one way to do this, which is through the http://unity3d.com/support/documentation/ScriptReference/Physics.GetIgnoreLayerCollision.html function.

You basically scan the layer array, and call the layer collision getter with your reference layer as a source. Then you can decide how to manage that, for example by populating a custom array or matrix (there seems to lack a specific such object in the physics panel to access).

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 Bezzy · Oct 28, 2011 at 04:48 PM 0
Share

Ahh, so there is a way, albeit brute force. Thanks!

As it turns out, I found a work around using rigidbody.SweepTest - this obviously ignores itself when doing the sweep, while Physics.SphereCast needs to be told which layers to include.

avatar image roamcel · Oct 29, 2011 at 06:04 AM 0
Share

Hah, that's a nice trick. Thanks for sharing 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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to achieve this basic physics effect? Detect when to change layers 2 Answers

How do I use layermasks? 9 Answers

Colliders attached to objects on separate layers are colliding? 1 Answer

Compute inertia tensor based only on colliders in same layer as parent? 0 Answers

Enable / Disable Layer Collision Matrix thru Script 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