# BindComparisonToUnityEvent

This one is a bit trickier but is the most useful. Find the Game Over Screen.&#x20;

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfvFPRIqYGHiUqb6YxwZhAg6ctw9cPK5rnZakXTO-OPSuwqug9wfjS50JqC1VUJ7lslRviArbAKu9BFtzZQEYsRGAQ2k08ndGNjn73lzCX6PVPWaOEOgn72xSDSL-9S5AXTJn-_GDdn9EwVx-HRXEAhe3pk?key=rYLTnURk3bHoj7o_CLwGjQ" alt="" width="375"><figcaption></figcaption></figure>

You can see that there are 2 BindComparisonToUnityEvent components on this panel.&#x20;

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdivBWpvfpfde6sOUi1HU_2FV8ysMB2Aj6MPYj95BEPeiI725ZjAiTcg3GRwaCLXkPUgizr6mKlAGIJIkulPnyGVJk65IfxB5bpEUynHkgscSqgSAG9V9DZeTpIp23qu_WEgBVwr1JdPoBtpcvTbbL-vPeJ?key=rYLTnURk3bHoj7o_CLwGjQ" alt="" width="375"><figcaption></figcaption></figure>

Now enter play mode and set the health to 0 using the health slider. Then, once the game over panel appears, set the health back to 100. &#x20;

It might seem a bit overwhelming at first, but it is simple. Here is what happens:&#x20;

The first component (1) does the following:&#x20;

* Binds itself to example\_float\_currentHealth variable.&#x20;
* Checks if the variable value is smaller or equal to 0 (when it changes).&#x20;
* If true, triggers the unity event. In this case -> enable the gameObject.&#x20;

The second component (2) does the following:&#x20;

* Binds itself to example\_float\_currentHealth variable.&#x20;
* Checks if the variable value is bigger to 0 (when it changes).&#x20;
* If true, triggers the unity event. In this case -> disable the gameObject.&#x20;

This check happens also on Start(), to make sure the conditions are validated at the start of the game (in this case the game over screen will be hidden as the health is set to 100). &#x20;

This is useful for menus, pop ups, VFX and other stuff when you don’t want to make a script to handle simple behaviors.&#x20;

Many things can be resolved with Unity Events. I recommend using unity events for visuals feedback and juice and not for actual game logic. You can consider them as “hooks” where you can attach nonessential things to your game.&#x20;

Note: Unity events creates more garbage than traditional C# events, so they are not the most performant. However, I have used them in mobile games and so far, never had an issue with them. &#x20;
