Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IT'S Health script
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Healthship : MonoBehaviour
- {
- public int maxhealth = 100;
- public int health;
- void Start()
- {
- health = maxhealth;
- }
- void FixUpdate()
- {
- maxhealth = health;
- if (health < 0)
- { health = 0; }
- if (health <= 0)
- { Destroy(gameObject); }
- }
- void Update()
- {
- Debug.Log(health);
- }
- }
- IT'S Damage script
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class damage : MonoBehaviour
- {
- public Healthship hp;
- public int damag = 10;
- void Start()
- {
- }
- void OnCollisionEnter(Collision col)
- {
- if (col.gameObject.tag == "Ship")
- {
- hp.health -= damag;
- }
- if (hp.health <= 0)
- {
- Destroy(gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement