For context, I'm working on a top-down 2D game with controls similar to 2D Zelda games.
What I'm trying to achieve: An impassible "pit" with moving platforms traveling back and forth across it, which the player can walk onto to traverse the pit. If the platform is adjacent to a non-pit tile or another platform, the player should be able to walk from the current platform to that place.
![](https://godotforums.org/assets/files/2022-10-25/1666740809-774510-image.png)
The problem: At first I implemented the pit as a Tilemap with collision to make it impassible to the player, and the moving platform as an Area2D moving along a Path2D. However, the pit's collision shape would not allow the player to walk onto the platform, since the platform exists entirely "within" the pit. I wish I could subtract the platform's area from the pit's collision shape, but I'm not sure that's possible.
My current (bad) solution: Instead of relying on the pit Tilemap's collision shape, I turned off the its collision and wrapped the pit with invisible barriers that prevent the player from crossing into the pit (shown as red outlines below). I surrounded the platform with the same barriers too, so the player can't walk off the platform and into the pit.
![](https://godotforums.org/assets/files/2022-10-25/1666740880-118474-image.png)
Now, in order to allow the player to walk onto or off of the platform, I have to disable the barriers at the place where I want the player to be able to walk.
![](https://godotforums.org/assets/files/2022-10-25/1666740913-991859-image.png)
Now the player can walk onto the platform, but I have to specify exactly when to turn off and on the barrier collision, and exactly which portions of the barrier to disable.
Is there a better to implement this, possibly a way that requires less manual intervention?