How to Destroy player when missFire ??

I used ScreentoWorld Function to fire and used lookat function to look at specfic position . i want to destroy player if bullet missed enemy . how to do that can anyone show me way how to do that ??? Plz Guide me how to do that … Thanks .

Add comment

Together with the shoot you can fire a Raycast and check if the hited object is the enemy or something else.

Maybe you can place a collider as a wall behind the enemy so that whenever the bullet hits the collider instead of the enemy, you can trigger the function related to destroy player. Let me know if it works for you.

Keep track of two things-

  1. distance between player and enemy=d1
    2)distance between player and bullet.=d2

if(d1 less than d2) and still the collision has not occured between bullet and the enemy, use GameObject.SetActive(false) to make disappear both your player and the bullet(in case you are pooling the bullet instead of instantiating).