예제 #1
0
    void OnTriggerEnter(Collider collider)
    {
        Health health = collider.GetComponentInParent <Health>();

        if (collider.tag == "PlayerCollision" && health.PlayerID != _playerId && !_hit)
        {
            _hit = true;

            float multiplier = 1f;

            if (collider.name == "head")
            {
                multiplier = 2f;
            }

            SentPlayer.HitDamage = Damage * multiplier;
            if (health.TotalHealth <= Damage * multiplier)
            {
                SentPlayer.CmdUpdateFatalHitUI();
            }
            else
            {
                SentPlayer.CmdUpdateHitUI();
            }

            Destroy(gameObject);
            NetworkServer.Destroy(gameObject);

            health.TakeDamage(Damage * multiplier);
        }
        if (collider.tag == "DestroyableObj" && !_hit)
        {
            _hit = true;
            Destroy(gameObject);
            NetworkServer.Destroy(gameObject);

            collider.transform.GetComponent <ObjectHealth>().TakeDamage(Damage);
        }
    }