Forum rules - please read before posting.

ActionLists through script

ActionList actionList = gameObject.GetComponent ();
if (actionList == null)
actionList = gameObject.AddComponent ();

The example code you mentioned in the manual should go into new MonoBehaviour script. What method should it go under
Awake, Start. Update or something else. It should drop under trigger, if I want to do something when player enter that trigger. Please excuse my ignorance. I am new getting into game dev.



  • The code above would typically go in a Start function, if you want it to generate an ActionList when the scene begins.

    Actually, for a better example, see the included ScriptedActionListExample.cs script file, where that code is placed in its own "CreateActionList" function.

    That script has two examples that are run by clicking the cog menu in the Inspector - but you can have either one of them run when the game begins by replacing their function name (either RunExampleOne or RunExampleTwo) with Start.

    Running an ActionList through script is done by calling its Interact() function - see the end of the RunExampleOne / RunExampleTwo functions. But if you're using a Trigger, you'll want to generate a Trigger instead.

    For this, just replace instances of the word "ActionList" with "AC_Trigger". Its default properties are such that it will run when a Player enters it - see its entry in the Scripting Guide here.

    If you need more assistance, I think you'll need to explain more thoroughly what you're trying to achieve here. For what reason are you trying to script this? Alternatives may be available.

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.