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