using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class herorun : MonoBehaviour
{
public float ziplama_hizi = 1f;
public float hareket_hizi = 5f;
public float yatayhareket;
public int damage;
public Animator animator;
public Rigidbody2D rb2D;
bool canAttack = true;
bool faceRight = true;
Vector2 forward;
public Vector3 offset;
RaycasHit2D hit;
void Update()
{
public void Attack()
{
canAttack = false;
if(!faceRight)
{
forward = transform.TransformDirection(Vector2.right * -2);
}
else
{
forward = transform.TransformDirection(Vector2.right * 2);
}
RaycasHit2D hit = Physics2D.RaycasHit2D(transform.position, forward, 1.0f);
if (hit)
{
if(hit.transform.tag == "Enemy")
{
hit.transform.getComponent<EnemyHealt>().GetDamage(damage);
}
else
{
Debug.Log("burada bir sey yok");
}
}
animator.SetTrigger("VurmaAnim");
StartCoroutine(AttackDelay());
}
IEnumerator AttackDelay()
{
yield return new WaitForSecond(0.5f);
canAttack = true;
}
if(Imput.GetKeyDown(KeyCode.F) && canAttack)
{
Attack();
}
}
}