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
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.
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.