So, my goal is to have an actor/character wait (or loop a task) until another actor finishes their own task.
An example would be:
Woman is cutting down a tree.
Boy is running toward her for a greeting.
Once boy finishes task (of running toward her), she stops axing to interact with him.
This is RPG 101, but I’m not sure what the terminology is to find the correct solution.
probably you have your task coming from some parent class like “task_base”.
In the base class, you might have a boolean or maybe some enum to describe how each task subclass interacts with interruption.
It could be simple, boolean “can / cannot be interrupted” or something more complex like having a priority. e.g. “cut down tree” has priority 10 and “start a conversation” is 20, therefore is ActorA’s currenttask has priority 20 and it is requesting to interrupt ActorB whose current task has priority of 10, the higher one wins.
When a task is finished it should fire off an event like “OnTaskFinished” and then in your task queue the next task is either going to be the default routine or if another actor has requested interruption, that would become new task.
Just some ideas. I am not expert, I’ve done something vaguely similar. The “command pattern” is what I am using to make a queue for task that can be manipulated.
You can have a trigger box collision around the woman and when the boy overlaps the box collision you can
have The collision box do something like - Get actor of Class(I’m assuming you have one of each of these pawns and there aren’t copies around them or else this is not so good)-Or get the references from “Get overlapped actors” or something like that. from the reference to the pawn you can call a “Custom Event” made in that actor(or both depending how you set it up) That “Custom Event” will tell the Boy or Woman to do their new actions now. you can either have the Collision Box send to BOTH pawns OR you can send it to ONE that has code the sends off to the OTHER using a similar method.
IE Box gets actor of class then calls “Custom Event” on that pawn that tells it what to do and at the end the Pawn does another “Get actor of class” starts a “Custom” event on the other Pawn that tells it what to do.
Oh, when it comes to NPCs, I’m very particular about classing them. Thank you for this idea. Ugh. I guess I’ll have to try these out and see what works best for me.