How do I temporarily ignore PlatformEffector2D collisions?

I’m currently using a PlatformEffector2D to handle one-way collisions for semisolid platforms.

I want my character to be able to fall through these semisolid platforms when Down + Jump is pressed. My character also has a Bat Form transformation and I want the Bat Form to ignore semisolid platforms entirely. In the Bat Form I’m not applying gravity at all.

I still want my character to not be able to go through the ground and walls, I just want to temporarily ignore my semisolid platforms.

I’m not sure how relevant it is either but I turned off Auto Simulation and I’m running Physics2D.Simulate every frame, I’m not sure if that will affect any suggestions.

Thanks in advance!

Ok, so I think I sort of figured this out, but I’m missing one more piece of the puzzle.

I have the following layers configured.

Player
Enemy
Player-IgnoreOneWay
Enemy-IgnoreOneWay

For my Ground LayerMask, I have all 4 of these layers set. For my Semisolid Platforms LayerMask, I only have Player and Enemy set.

If I go to the inspector, then change my player to Player-IgnoreOneWay, it doesn’t have any collisions with the PlatformEffector2D at all, this is good, this is the behavior I want.

HOWEVER, when I try to change it in code it doesn’t work.

Here’s the code I’m using to set the layers.

// To allow semisolid platform collisions
gameObject.layer = LayerMask.NameToLayer("Player");

// To disallow semisolid platform collisions
gameObject.layer = LayerMask.NameToLayer("Player-IgnoreOneWay");

During runtime I can see that the layer actually does get changed, but the collisions still happen.

Do I need to trigger something else during runtime to make this work?

EDIT: Nevermind, now I feel really stupid. I forgot I put my colliders on their own game objects so that I can use a different collider for each of my character’s transformations (Human, Wolf, Bat) without having to manipulate the size via code and I was setting the layers of the wrong object.

I no longer need help with this issue.