Beispiel #1
0
    public virtual void TakeDamage(DamageData data, Vector3 forward, Fighter owner)
    {
        if (invincible)
        {
            return;
        }

        currHealth -= data.GetDamage(); // Lose health from damage

        if (animator)
        {
            animator.SetBool("hurt", true);
        }

        hitstunning = true;
        if (data.GetDamage() > 0)
        {
            onHurt.Invoke();
        }

        //forward.y = 1f; // For knockback

        // Death
        if (currHealth <= 0)
        {
            currHealth = 0;

            if (rb)
            {
                rb.velocity = Vector3.zero;    // Cancel velocity
            }
            if (!dead)
            {
                Die();
            }

            return;
        }

        if (data.GetDamage() > 0)
        {
            rb.velocity = Vector3.zero; // Cancel velocity

            Knockback(data, forward);
        }
    }