Destroy object when not looking

How do i make it so that when a player rotates their view a certain amount (possibly rotation view like 180) an object will be destroyed.

basically im making an enemy chase a player, and if the player turns away i want the enemy to disappear (destroy)

thinkin maybe a ray cast… idk

You can try the OnBecameInvisible() method under MonoBehaviour. Attach this to the player. This is assuming the player is a first person view. If its a 2d view with the bot chasing the player, then you can check for the specific range of angle in Update() function and destroy the bot.

GameObject bot;

void OnBecameInvisible(){
    Destroy( bot );