public void CauseDamage() { charMove.FindNearestTarget(); if (charMove.targetUnit != null) { Vector3 a; a = (Mathf.Abs(transform.position.y - charMove.targetUnit.transform.position.y) <= 1) ? new Vector3(1, 0, 1) : new Vector3(1, 1, 1); if (Vector3.Distance(Vector3.Scale(transform.position, a), Vector3.Scale(charMove.targetUnit.transform.position, a)) <= 1) { Character character = charMove.targetUnit.GetComponent <Character>(); newDamage = new Damage { actor = this, target = character, damage = this.baseDamage, critModifier = this.critModifier, armourPierce = this.armourPierce, canBeDodged = true, canBeBlocked = true, actorTriggerList = this.triggerList, targetTriggerList = character.triggerList, }; //Debug.Log("Total damage: " + character.TakeDamage (newDamage).damage); character.TakeDamage(newDamage); SetActionState(Actions.Attack, true); } } }