void Shoot() { RaycastHit2D hit = Physics2D.Raycast(firePointPosition, mousePosition - firePointPosition, range); Debug.DrawLine(firePointPosition, (mousePosition - firePointPosition) * range, Color.cyan); if (hit.collider.gameObject.layer == 11) { health = hit.collider.GetComponent <BlockHealth>(); // Debug.Log("We hit " + hit.collider.name + " and did " + Damage + " damage."); health.shot(Damage); } }
private void HitBlock() { if (currentBlock != null) { if (!currentBlock.GetComponent <Pickup>()) { blockHealth = currentBlock.GetComponent <BlockHealth>(); minePower = equippedInventory.activeItem.GetComponent <PickaxeInfo>().pickaxe.miningPower; blockHealth.takeDamage(minePower); colliderInBlock = false; } } }