Скрипт для монстру з кількома життями

Постріл, приймає префаб з асетів

        public GameObject startPosition;

        public GameObject Obj;

    void Update()

    {

        if (Input.GetKeyDown(KeyCode.LeftAlt))

        {

    GameObject go = Instantiate(Obj, startPosition.transform.position, startPosition.transform.rotation) as GameObject;

            go.transform.position = startPosition.transform.position;

            go.GetComponent<Rigidbody2D>().velocity = Vector2.zero;

            go.GetComponent<Rigidbody2D>().angularVelocity = 0;

            if (transform.localScale.x > 0)

            {

                go.GetComponent<Rigidbody2D>().AddForce(transform.right * (7000));

            }

            else

            {

                go.GetComponent<Rigidbody2D>().AddForce(transform.right * (-7000));

            }

        }

    }

Монстр

   public int z = 0;

   public int a = 1;

    void OnTriggerEnter2D(Collider2D other) 

    {

        if (other.tag == "Player")

        {

             //  Coin.a=0;    

             UnityEngine.SceneManagement.SceneManager.LoadScene(z);

        }

        else 

        {

        a--;

if(a<1){


                    Destroy(gameObject);

            Destroy(other.gameObject);


}

                else{


    Destroy(other.gameObject);

}

        }

    }