Another obstacle in the dungeons for the player to avoid, our idea is that they will deal a large amount of damage to the player if they were to fall into them, and then respawn the player in the room after they had fallen.
The PitFall scripts starts with references to a Transform component called playerRespawn, which is where the player will respawn upon falling into the pitfall and a reference to an int damage = 2; , the amount of damage that will be dealt to the player if they fall into the pitfall.
This Pitfall game object also has a BoxCollider2D component which is set to trigger. Which is used in the OnTriggerEnter2D() method to check if what has collided with the pitfall is the player. If it is the player, it will cause the player to take 2 HP of damage and prevent them from moving or attacking.
Then a Fall() coroutine is called which waits for 1 second (For a future fall animation to play), then takes the player to the playerRespawn transform and then re-allows the player to move and attack.

After implementing the Pitfall, we decided to allow thew player to dash over them, documented in this Development Post.
Updating the Pitfall

After the playtest, we had a lot of feedback concerning the pitfall. Players felt it was much too buggy to have the respawn point be a static point on in the room as opposed to it being that last area in the room the player stood on before falling into the pitfall. Furthermore, enemies were still active as the player went through the motions of falling into the pitfall and respawning – allowing them, on occasion, to deal damage to the player without the player being able to do anything.
These were two large issues with the pitfall, however, instead of fixing the issues directly, we felt it was best to redesign the pitfall entirely. This was due to my lack of Unity and C# experience up to this point, despite being the group’s primary programmer and we felt this would save us a lot of time

Ultimately, we decided to change the pitfall into an obstacle that doesn’t do damage but merely as a ‘wall’ type collider that the player can only move through by dashing. This would be a lot easier to implement and would work similarly to other existing 2D roguelike games (such as The Binding of Isaac).

To prevent the player from walking through Pitfalls, I gave them a BoxCollider2D component. However, the player would still need to be able to dash through them. In order to do this, I created a new Layer called “PlayerCanDashOver” and assigned it to the pitfall prefab. Then, in the Dash() method in the player’s PlayerControllerNew script, I used the Physics2D.IgnoreLayerCollision function and inputted the players’ layer and the pitfall’s layer. This would prevent the player’s Collider component and the pitfall’s Collider component from colliding during the player’s dash.