In code, I can reference these layers by their index values. In Unity, when a trigger collider hits another collider, we can listen for this event using several API functions. The one I will be using is OnTriggerEnter. Let's take a look at the code that is needed for handling death.
The alive variable allows us to control whether we should listen to player input. By wrapping the input code with an if statement that checks if the player is alive, I can stop the player from jumping once the bird hits something. Notice in the Death method, we send out an event call and this is because other systems such as the ColumnScroll script needs to stop their scrolling when the player dies. So in the ColumnScroll, we do something like the following.
This wraps up most of the core functionality I used in Unity and its Unity2D API to create a FlappyBird clone. If you have a question or feedback, feel free to leave a comment below!