Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Projectile : MonoBehaviour
- {
- public string targetClass;
- public string target_Tag;
- public float damage_Val;
- public float proj_Duration;
- DroneHealth droneHealth;
- ShipHealth shipHealth;
- // Start is called before the first frame update
- void Start()
- {
- Destroy(this.gameObject,proj_Duration);
- }
- // Update is called once per frame
- void OnTriggerEnter2D(Collider2D col)
- {
- target_Tag = col.gameObject.tag;
- Debug.Log("Collided with:" + gameObject.name);
- if(((target_Tag == "Enemy_I")||(target_Tag == "Player_I")) && (target_Tag != "projectile"))
- {
- //Debug.Log("Hit:"+col.gameObject);
- droneHealth = col.gameObject.GetComponent<DroneHealth>();
- droneHealth.Damage(damage_Val);
- Destroy(this.gameObject);
- }
- if (((target_Tag == "Enemy_C") || (target_Tag == "Player_C")) && (target_Tag != "projectile"))
- {
- //Debug.Log("Hit:"+col.gameObject);
- shipHealth = col.gameObject.GetComponent<ShipHealth>();
- shipHealth.Damage(damage_Val);
- Destroy(this.gameObject);
- }
- }
- }
Add Comment
Please, Sign In to add comment