Пример #1
0
    protected virtual void NetGetHit(string bodyPartHit, string hitVector, int damage, int knockbackForce)
    {
        Vector3 hitNormal = HelpfulFunctions.StringToVector3(hitVector);

        if (bodyPartHit == "Eye")
        {
            damage = Mathf.RoundToInt(damage * criticalHitMultiplier);
            audioSource.PlayOneShot(eyeHitSound);
        }
        else
        {
            audioSource.PlayOneShot(hitSound);
        }
        health -= damage;

        if (health <= 0)
        {
            Die();
        }

        if (knockbackEnabled)
        {
            rb.AddForce(-hitNormal * knockbackForce, ForceMode.Impulse);
            rb.AddTorque(hitNormal * knockbackForce, ForceMode.Impulse);
        }
    }
Пример #2
0
 void NetProjectileHit(int index, string hitPoint)
 {
     if (hitParticles != null)
     {
         Vector3 hitVector = HelpfulFunctions.StringToVector3(hitPoint);
         Instantiate(hitParticles, hitVector, Quaternion.identity);
     }
     Destroy(projectiles[index], .5f);
 }