Hello,
I have an NPC moving in background using cutscene from one point to another. (Action in scene with Run in Background).
I want that when another cutscene that pauses gameplay (has set "when running" to "pause gameplay") and involves that NPC to make him stop moving from point to point and run a talk animation.
The Kill() method doesn't stop MoveToPoint for some reason. The character just moves to the point and gets stuck like below.
Each Walks and Runs are a List with a MoveToPoint Action.
IEnumerator GoToTarget() {
yield return new WaitForSeconds(1);
while (true) {
if(alm == null) {
yield return new WaitForEndOfFrame();
}
if (alm.IsGameplayBlocked()) {
for (int j = 0; j < Spots.Count; j++) {
if (Walks[j].AreActionsRunning()) {
Walks[j].Kill();
}
if (Runs[j].AreActionsRunning()) {
Runs[j].Kill();
}
}
yield return new WaitForSeconds(0.5f);
continue;
}
int i = 0;
float dist = Mathf.Infinity;
//find the closetest point
for (i = 0; i < Spots.Count; i++) {
if (dist > (Spots[i].transform.position - Kitteh.position).magnitude && IsOk(Spots[i])) {
dist = (Spots[i].transform.position - Kitteh.position).magnitude;
close = i;
}
}
//check if an action is running
bool walkOrRunIsRunning = false;
for (i = 0; i < Spots.Count; i++) {
if (Walks[i].AreActionsRunning()) {
walkOrRunIsRunning = true;
}
if (Runs[i].AreActionsRunning()) {
walkOrRunIsRunning = true;
}
}
//run if far away
if ((Kitteh.position - Buzz.position).magnitude > 6f) {
if (!walkOrRunIsRunning) {
Runs[close].Interact();
}
}//walk to point
else if ((Kitteh.position - Buzz.position).magnitude > 2.5f) {
if (!walkOrRunIsRunning) {
Walks[close].Interact();
}
}//run to point
else if ((Kitteh.position - Buzz.position).magnitude < 1f) {
if (!walkOrRunIsRunning) {
Runs[close].Interact();
}
}
yield return new WaitForSeconds(0.5f);
}
}
Comments
Halting the character manually is indeed the method required, and pausing/resuming the ActionList should also allow you to return afterwards. You can do these via the Character: Move along path and ActionList: Pause or resume Actions respectively - which may be easier than coding it.
However, restarting the ActionList should cause the Action to re-run, and if the blue line is showing it sounds like it is - but not having an effect.
You can confirm that the Action is running by toggling on a comment (top-right corner icon of the Action), and outputting it to the Console from the bottom of the Settings Manager. Incidentally, do any other messages appear in the Console?
This actually sounds like an issue with your character rather than the ActionList system. Can you try placing in Brain2D, from the 2D Demo, and trying him out? I can't recreate this problem by following your steps with him.