Another way to avoid Combat and Movement coupling

Hello,

Instead of creating the StartMovement method in Mover.cs, I put it in the PlayerController.cs to avoid Combat and Movement coupling and the code is working as expected. But will this create any other problem?

It works in the short term, but will become an issue if you start to try other types of Actions, such as in the final course in the series when we introduce Abilities. It will also break when we refactor to make raycasts handled by components rather than the PlayerController making direct decisions.

Additionally, while it isn’t directly covered in the course, if you want to restrict the click range of things like clicking on an item pickup (Inventory), or only being able to speak to a character when close (Dialogues and Quests) , or shopping from a Vendor (Shops and Abilities), you’ll need to create collector classes that work light Fighter to move to the target before finishing the interaction. The more interactions you add, the more of these specialized methods like your StartMovement you’ll need, each one trying to cancel all of the other possible actions.

This is why we use the ActionScheduler. No worrying about what (if any) action is current, just automatically cancelling whatever the current Action is.

Thanks. I look forward to write code for all those things.

Thanks for that!

I was already wondering what the point was of getting so complicated when I could deal with that rather easily and without creating circular dependencies in PlayerController.

Time to fire-up the repo and work on a different version I guess :slight_smile:

Privacy & Terms