Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do I reset the Layer Collision Matrix?

Discussion in 'Physics' started by JohnnyFactor, Feb 22, 2019.

  1. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    Layer collision setups are carried over between scenes and can cause problems when not tracked. I cannot find any scripting reference to access the Layer Collision Matrix except for Physics.IgnoreLayerCollision. Is this accessible from C#?

    EDIT: I solved this the correct way and set each IgnoreLayerCollision to false before closing out the scene.

    Code (CSharp):
    1. public void Awake()
    2. {
    3.     Physics.IgnoreLayerCollision(11,12);
    4. }
    5.  
    6. public void CloseScene()
    7. {
    8.     Physics.IgnoreLayerCollision(11,12, false);
    9. }
     
    Last edited: Feb 24, 2019