I am sorry for so much redundancy, but I can’t kill my enemy and there is no reason I can see.
GameObject GestureAttack()
{
invincible = true;
GameObject[] Foes = GameObject.FindGameObjectsWithTag("Foe");
GameObject closest = null;
float distance = Mathf.Infinity;
Vector3 position = transform.position;
s_PlayerControl enemyHealth = GetComponent<s_PlayerControl>();
foreach (GameObject go in Foes)
{
FoeCurrentHealth = go.GetComponent<s_EnnemyControl>().FoeCurrentHealth;
Debug.Log(FoeCurrentHealth);
Vector3 diff = go.transform.position - position;
float curDistance = diff.sqrMagnitude;
if (curDistance < distance)
{
closest = go;
distance = curDistance;
}
}
Here is my problem (Took is log). But even with a substraction I can’t damage them.
if (recupgeste == "D" && recupgestescore > 0.60 || Input.GetKeyDown(KeyCode.Space))
{
transform.position = Vector3.MoveTowards(transform.position, closest.transform.position, 100);
// foreach (GameObject go in Foes)
//{
Debug.Log(enemyHealth.FoeCurrentHealth);
if (FoeCurrentHealth >0)
{
Debug.Log("TOOK");
enemyHealth.TakeDamage(attackDamage);
//}
}
}
return closest;
}
They always have one point of life…