@@ -35,6 +35,7 @@ public class Fighter : MonoBehaviour, IAction, ISaveable, IModifierProvider {
3535 private CinematicControlRemover [ ] cinematicControlRemovers ;
3636
3737 public event Action updateTargetUI ;
38+ public Health Target => target ;
3839
3940 private void Awake ( ) {
4041 mover = GetComponent < Mover > ( ) ;
@@ -72,7 +73,7 @@ private void Update() {
7273 return ;
7374 }
7475
75- if ( ! GetIsInRange ( ) ) {
76+ if ( ! GetIsInRange ( target . transform ) ) {
7677 mover . MoveTo ( target . transform . position , 1f ) ;
7778 stopped = false ;
7879 } else {
@@ -99,16 +100,16 @@ private void AttackBehaviour() {
99100
100101 private void MakeEyeContact ( ) {
101102 characterBehaviour . LookAtTarget ( target . transform ) ;
102- target . GetComponent < CharacterBehaviour > ( ) . AttackedBy ( gameObject ) ;
103+ target . GetComponent < CharacterBehaviour > ( ) . LookAtTarget ( gameObject . transform ) ;
103104 }
104105
105106 private void TriggerAttack ( ) {
106107 animator . ResetTrigger ( STOP_ATTACK_TRIGGER ) ;
107108 animator . SetTrigger ( ATTACK_TRIGGER ) ;
108109 }
109110
110- private bool GetIsInRange ( ) {
111- return IsTargetInRange ( transform , target . transform , currentWeaponConfig . Range ) ;
111+ private bool GetIsInRange ( Transform targetTransform ) {
112+ return IsTargetInRange ( transform , targetTransform , currentWeaponConfig . Range ) ;
112113 }
113114
114115 // Animation Trigger
@@ -140,15 +141,13 @@ private void StopAttack() {
140141 animator . SetTrigger ( STOP_ATTACK_TRIGGER ) ;
141142 }
142143
143- public Health Target => target ;
144-
145144 public void EquipWeapon ( WeaponConfig weapon ) {
146145 currentWeaponConfig = weapon ;
147146 currentWeapon . value = weapon . Spawn ( rightHandTransform , leftHandTransform , animator ) ;
148147 }
149148
150149 public bool CanAttack ( GameObject target ) {
151- if ( target == null || ! mover . CanMoveTo ( target . transform . position ) ) {
150+ if ( target == null || ( ! mover . CanMoveTo ( target . transform . position ) && ! GetIsInRange ( target . transform ) ) ) {
152151 return false ;
153152 }
154153
0 commit comments