Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class enemy2 : MonoBehaviour {
- public int Hp = 3;
- GameObject bullet;
- // Use this for initialization
- void Start () {
- bullet = GameObject.Find("bullet");
- }
- // Update is called once per frame
- void Update () {
- }
- void OnCollisionEnter2D(Collision2D coll){
- if(coll.collider.tag=="Bullet")
- {
- Hp--;
- Destroy (bullet);
- if(Hp<=0){
- Destroy (gameObject);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement