PJ/Assets/scripts/SwordAttack.cs

33 lines
732 B
C#
Raw Normal View History

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<ArmorOnPlayer>().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<EnityControl>().Lives -= damage;
}
}
private void OnTriggerExit2D(Collider2D collision)
{
att = true;
}
}