public float n_attack;
private bool D_ma;
private bool stop;
public float D_m;
private bool collision;
public Player pl;
public GameObject losing;
float timer = 0;
private void OnCollisionEnter2D(Collision2D collision_obj)
{
if (collision_obj.gameObject.tag == "Player")
{
collision = true;
}
}
void Update()
{
if (collision == true && D_ma == false)
{
pl.player_health -= (n_attack - pl.player_deference);
D_ma = true;
}
if (D_ma == true && stop == false)
{
stop = true;
pl.player_deference -= D_m;
}
if (D_ma == true)
{
while(timer < 4)
{
timer ++;
}
if (timer == 3)
{
D_ma = false;
timer = 0;
}
}
if (pl.player_health == 0 || pl.player_health < 0)
{
losing.gameObject.SetActive(true);
}
}