public void CastDrain() { if (!myUnitId.isServer) { return; } int counter = 0; foreach (var unit in unitsInRange) { if (unit != null) { Unit currentUnit = unit.GetComponent <Unit> (); if (!currentUnit.isDying && !currentUnit.isDead) { myVampire.RpcDrainUnit(currentUnit.netId); Instantiate(drainParticle, unit.transform, false); counter++; if (counter >= maxDrainNumber) { break; } } } } }