Forum rules - please read before posting.

Stop action list - do script - restart action list?

Hello all,
I have an NPC who patrols a small area (MoveOnNewPath loop, starts with OnStart cutscene). He has attached a cone mesh ("field of view") as a trigger. I want to run my script (catch Player/ NPC follow - something like this) when Player stays in trigger and when he leaves trigger (trigger exit) - NPC will return to the path.
I made a boolean global variable (isTriggerOn), and in ActionList adds VariableCheck before CharacterMoveAlongPath, but when move along is started - never back to the VariableCheck later (so NPC is patrolling area the rest of the time and ignoring Player).
In other pseudo-codewords (sorry for my English, I'm learning it):
if(isTriggered)
{
ActionList(Stop);
Chase();
}
else
ActionList(Run);

Thanks for all answers! :) 


Comments

  • edited January 2018
    Welcome to the community, @KosaJr.

    I'm afraid I'm not understanding your meaning too well.  If you could share some screenshots, that might make it more clearer.

    When an ActionList is begun, it can begin either from the start, or from any Action.  The ActionList: Run Action has a Run from start? option, and the Interact method can take the starting Action index as a parameter.

    Alternatively, you could break up the ActionList into two: so that the Variable: Check and Character: Move along path Actions are in separate lists.  The Variable: Check Action could then run the list with the Character: Move along path Action, as could the trigger code.

    Also, know that a character can be made to resume their last path - which may be necessary if you need the patrolling NPC to pick up where they left off.  This can be done with another Character: Move along path Action - though you would also need to first stop the character using this same Action before also killing the patrolling ActionList.  This can also be done through the ResumeLastPath and EndPath methods respectively.

    To see a full list of the functions available to you in the ActionList script, see its entry in the scripting guide here.
  • Thanks for reply, Chris.

    Screenshot:image

    The IsChasing variable from first state is changing via script (OnTriggerStay -> true).
    The problem is: actionlist checks variable only once at start (Interact() via script). If IsChasing is false, State 1 (Run) starts in an infinite loop.
    In other words: Guard is patrolling area. But when he sees Player, he attempts to chase him. If player disappears, he goes back to patrol.

    Aww, my English is terrible, sorry about that.
  • I'm not sure a variable and continuously-running Trigger is the way to go.  A Trigger can be set to react when a collider enters it, as well as exit it.

    You can attach more than one AC_Trigger component to the same object and have one detect entries, and the other detect exits - see the 3D Demo scene's SwitchNavCam object for an example.

    Otherwise, you could introduce an ActionList: Check running Action in between Action #0 and #1 to prevent #1 from being triggered if al_EnemyPatrol is already running.

    But if you're pausing the ActionList, you'd really want to resume it instead of re-run it.  You might need to set Action #1 to another ActionList: Pause or resume, with the Method set to Resume.  Otherwise, there's no point in pausing it - Action #2 could just be an ActionList: Kill Action to kill the al_EnemyPatrol list completely.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.