I want to know your opinions on this. Since Playercontroller.cs already have dependency of Combat and Movement why don’t we just stop the attack on this level with a single line of code. The only thing that is doing is setting the target on fighter to null and in update is simply doing a return on the first line.
If you’re absolutely positive that nowhere in the future you might want to have other actions, this will work just fine, but every action you add will increase the number of components you’ll need to cancel with each new action…
Here’s an example: Suppose I want to cast a healing spell, and want a full blown animation go with the heal spell… now I need:
if(Input.GetMouseButton(0))
{
GetComponent<Fighter>().Stop();
GetComponent<Caster>().Stop();
GetComponent<Mover>().MoveTo(hit.point);
}
bear in mind, I’ll need to do the same when fighting or casting…
Now add a 4th action… The added lines of code continue to rise dramatically the more you add, and more to the point, in order to add an action at all, you’ll have more opportunities to miss one of these cancellations…
The ActionScheduler simplifies this. It may seem like overkill with just a Mover and a Fighter, but the principle scales easily and requires little awareness of other types of actions…
When we get later in the course, we’ll be interacting with components themselves, and letting components decide what action should be called. This layer of abstraction will keep each component from having to know anything about the other to do their job.
I think you are referring to the fact now Movement depends on Combat and Combat depends on Movement resulting in a circular dependency.
I was also pondering about this. But later Sam said he will have a solution for this problem in the next video.