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 testinapuzz · Nov 19, 2020 at 12:47 PM · 2d2d gamebug2d-physics2d collision

2D collision matrix does not work in unity 2020

I am trying to make a system where when the player pushes on button he changes layer from "Player layer" to an "invicible layer" where the player can't collide with enemy or other objects. so i created the "enemy" and "the invicible" layers and disabled the collision between the two from the 2d collision matrix but the collision still happens. i tried to set the player to the invicible layerfrom the start to make sure there wasn't a problem with changing layers with the script but the collision probblem still persisted. I tried using various functions like Physics2D.IgnoreLayerCollision(10,11, true) and Physics2D.IgnoreCollision(enemy.GetComponent(), player.GetComponent()); but nothing changed. To better understand the problem i tried disabling (i tried with all the methods above) the collision between player and an object in the scene (because i have more control on the player movement) and i saw that the collision still happens when i move horizontally but if jump on the object the player ignores the collision for a split second but then gets glitched "inside" the object. All of this problems exist only in unity 2020, not in 2019 but i can't use the 2019 version because i need to import some packages that are available only in the 2020 version.

At this point i just don't know what to do and i am quite desperate, any help would be much appriciated

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

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by sztobar · Nov 19, 2020 at 01:25 PM

  1. How do you detect a collision? Do you use Physics.Raycast(), collider.Cast() or anything like that, or do you detect it using OnCollisionEnter2D or OnTriggerEnter2D method call?

  2. Do the player and button have both rigidbody2d attached?

  3. Are any of the colliders have isTrigger flag enabled on it?

  4. Do you have in code any calls to IgnoreLayerCollision(10, 11, false) or anything that can potentially enable collision between those two?

Comment
Add comment · Show 3 · 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 testinapuzz · Nov 19, 2020 at 09:24 PM 0
Share

1 when i say the collision still happens i mean that the player still behaves like it's colliding with the box collider

2 yes they have rigidbody2d attached

3 no, none of the colliders is set to trigger

4 the IgnoreLayerCollision(10, 11, false) is called in an update method in a script attached to the player, i also tried calling it from both start and awake but nothing changed.

Also, thanks for trying to help, i hope to solve this problem asap

avatar image sztobar testinapuzz · Nov 20, 2020 at 10:21 AM 0
Share

I'm not sure if you made a typo, or mistaken an argument. Notice that: When you call IgnoreLayerCollision(10, 11, false) you enable collision between the layers. When you call IgnoreLayerCollision(10, 11, true) you disable collision between the layers.

You wrote that IgnoreLayerCollision(10, 11, false) is called in an update of the player. So you enable the collision on every frame.

avatar image testinapuzz sztobar · Nov 20, 2020 at 05:02 PM 0
Share

Ah, sorry it was a typo, i checked in the script is setting it to true

avatar image
2

Answer by Vishal0703 · Mar 22, 2021 at 11:25 AM

Are you sure you disabled the collision in Physics2D collision matrix and not in the Physics Collision matrix??? (I am assuming you are working on a 2D game here)... Was just having this issue and seems like I was disabling the collision in Physics collision... Disabling the same collision in Physics2D worked for me...

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 SteveHoward · Nov 19, 2020 at 01:52 PM

@testinapuzz I don't see the same problem in 2020.1. I created an obstacle in my game and set the layer to "test". I don't get a collision. Here is my collision matrix. Turning off collisions between test and Player. I didn't do the invincible layer but you said even if you change the layer to invincible it doesn't work.

[1]: /storage/temp/171260-project-settings-and-level1.png


project-settings-and-level1.png (30.9 kB)
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 testinapuzz · Nov 19, 2020 at 09:15 PM 0
Share

i did the same thing but on my project doesn't work, maybe i will try reinstalling unity

avatar image
0

Answer by atorstling · Aug 06, 2021 at 03:07 PM

I thought I had ran into this bug, but it turned out that I had enabled the "Use Collider Mask" option in a "Platform Effector 2D", which effectively overrode which layers this platform would collide with. That meant that it could create collisions between layers which weren't colliding according to the matrix. Bit of a facepalm, but yeah...

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

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

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

Related Questions

How to check if an object hits the ground hard enough then add explosive force around it (2D) 1 Answer

want to knock gameobject to the same direction as the projectile 1 Answer

Problem with 2D movement. My character is moving by himself between two points... :) 1 Answer

Unity 2D Lighting Effect 1 Answer

Why is there a gap between my player and the wall during wall slide? SOLVED 2 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