using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class SwordAttack : MonoBehaviour { public int damage; bool att; private void Start() { damage = gameObject.GetComponentInParent().Attack; Debug.Log("W"); } private void OnTriggerEnter2D(Collider2D collision) { Debug.Log("tring"); if (collision.tag == "Enemy" && att) { att = false; Debug.Log("Atacked"); collision.gameObject.GetComponent().Lives -= damage; } } private void OnTriggerExit2D(Collider2D collision) { att = true; } }