Why are we using an action scheduler?

so i am doing the course and i was wondering why we used an actionschduler?
if i added

GetComponent<Fighter>().Cancel();

inside my

private bool InteractWithMovement()
        {
            RaycastHit hit;
            bool hasHit = Physics.Raycast(GetMouseRay(), out hit);
            if (hasHit)
            {
                if (Input.GetMouseButton(0))
                {
                    GetComponent<Fighter>().Cancel();
                    mover.StartMoveAction(hit.point);
                }
                return true;
                
            }
            return false;
        }

on my playercontroller script works and is less complicated,
am i missing something that will be taught latter?

While that will work for now, as you add more components, you’ll find that explicit cancelling gets more and more complicated.

Thanks for the answer,

and yes further along the cancelling gets complicated and I noticed that further along it is confusing to follow along when i have different code.
In the end i do it my way in the challenges or even if i know what they are talking about i will pause the video and do it my self, test, then i will comment out my code and do it their way.

Thanks again

Darrin

2 Likes

That’s actually a good approach. You should always have a go at the challenges, and they won’t always be what Sam or Rick came up with. You might surprise yourself with a fragment of code that’s useful in another context! It’s fairly important, though, as the course progresses that your codebase doesn’t drift too far from ours. Not neccesarily because it’s the “right” code, but because it’s harder for us to help you out in later lectures if your codebase heads in a completely different direction.

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

Privacy & Terms