Need for the Scheduler when you can Cancel Combat from PlayerController class

Hi,
I am confused about the need for a scheduler when you can call the Fighter.Cancel() function from PlayerController class.

bool InteractWithMovement()
{
RaycastHit hit;

        bool hasHit = Physics.Raycast(GetMouseRay(), out hit);
            if (hasHit)
            {
                if (Input.GetMouseButton(0))
                {
                    GetComponent<Mover>().MoveTo(hit.point);
                    **GetComponent<Fighter>().Cancel();**
                }
                return true;
            }
            return false;
    }

Am I missing anything? I’d really appreciate it if you could make this clear to me.

We’re setting you up for more options…
I’ll use my own project as an example.
I don’t like the idea of being able to click on an item on the other side of the village and having it magically be picked up. I would prefer that the character at least got to the item, so I have a component ItemCollector… ItemCollector is called when an item is targeted, and like fighter, runs towards the item and picks up the item. If I click on something else I want this action cancelled.

In Dialogues and Quests, right now, we just start talking to the speaker no matter how close we are, so I made the component responsible for talking to a speaker make the character move to a speaker and then open a dialogue. This is also an action that needs to be cancelled when something else is clicked on. The same goes with a shop keeper. The list of possible actions is endless.

So it seems like we’re only cancelling Mover and Fighter at this time, but using these tools, you should see how you can add these and not need to change PlayerController at all…

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms