I had already added that, and I put the call to cancel the attack into the PlayerController
(because ultimately it should be the PlayerController
that’s in charge to determine whether the player is moving or attacking, to start with).
For the challenge it’s said to do it in the Mover
and this does add that complexity of further entangling Combat and Movement (which is mentioned in the video on adding a circular dependency), and also makes it more complicated because you need extra code to determine if MoveTo()
had been called as the result of the player clicking to a different location to move to (and retreat from combat) or because the Fighter
's Update()
is doing it in order to pursue an enemy that has moved out of range…
Depending on how one wants to do the combat one could have it that clicking on an enemy is primarily to set it as a target, and the fighting itself occurs on auto-pilot, and one might also want to have it that whenever the player had to change their position in order to pursue then one would have to explicitly engage again. That’s a matter of game design but I do think it’s not where the course project is going for…
So for now I will do the Cancel()
(or rather CancelAttack()
as I called it) from within MoveTo()
, and see how the lesson continues.