public bool shoot(GameObject attacker, GameObject target) { healthSystem = GameObject.Find("Manager").GetComponent<HealthSystem>(); currentplayerAttr = (AttributeComponent)attacker.GetComponent(typeof(AttributeComponent)); currentPlayerCell = currentplayerAttr.getCurrentCell(); currentPlayerWeapon = (WeaponComponent)currentplayerAttr.weapon.GetComponent(typeof(WeaponComponent)); if(attacker.tag == "FigurSpieler1") currentPlayerComp = GameObject.Find("Player1").GetComponent<PlayerComponent>(); else currentPlayerComp = GameObject.Find("Player2").GetComponent<PlayerComponent>(); currentTargetAttr = (AttributeComponent)target.GetComponent(typeof(AttributeComponent)); currentTargetCell = currentTargetAttr.getCurrentCell(); distanceBetweenPlayers = Vector3.Magnitude(currentTargetCell.transform.position - currentPlayerCell.transform.position); Debug.Log("Distance between players is " + distanceBetweenPlayers); if (playerCanShoot()) { float hitChance = chanceOfHittingTarget(); Debug.Log("Hitchance: " + hitChance); if (hitChance >= Random.value) { if (healthSystem == null) Debug.Log("Healthsys"); if (currentplayerAttr == null) Debug.Log("currentplayerAttr"); if (currentPlayerComp == null) Debug.Log("currentPlayerComp"); if (currentTargetAttr == null) Debug.Log("currentTargetAttr"); healthSystem.doDamage(currentplayerAttr, currentPlayerComp, currentTargetAttr, HealthSystem.SHOOT); return true; } else { return false; } } return false; }