コード例 #1
0
    //Damages if a bullet hits a player
    private void OnCollisionEnter(Collision other)
    {
        AUnit aunit = other.gameObject.GetComponent <AUnit>();

        if (aunit != null)
        {
            // If the collider is a Unit, take damage
            aunit.OnHit(_Damage);
        }
    }
コード例 #2
0
    protected void ShootLasersFromEyes(Vector3 hitPos, Transform other)
    {
        foreach (var eye in _Eyes)
        {
            Instantiate(_LaserPrefab).Shoot(eye.transform.position, hitPos);
        }

        AUnit otherUnit = other.GetComponent <AUnit>();

        if (otherUnit != null && otherUnit.TeamNumber != TeamNumber)
        {
            otherUnit.OnHit(_AttackDamage);
        }
    }