Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class enemy2 : MonoBehaviour {
  6. public int Hp = 3;
  7. GameObject bullet;
  8. // Use this for initialization
  9. void Start () {
  10. bullet = GameObject.Find("bullet");
  11. }
  12.  
  13. // Update is called once per frame
  14. void Update () {
  15.  
  16.  
  17. }
  18. void OnCollisionEnter2D(Collision2D coll){
  19. if(coll.collider.tag=="Bullet")
  20. {
  21. Hp--;
  22. Destroy (bullet);
  23. if(Hp<=0){
  24. Destroy (gameObject);
  25. }
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement