Forum rules - please read before posting.

Need to use Private Variables with Action Lists Assets

edited August 2016 in Technical Q&A
Hi, I'm trying to create an action list asset that can open or close a drawer. I want to give a parameter with the game object to animate and another one with a boolean to check the state it is currently set. Example: If the drawer is opened then close it, same the other way around. The problem is, they all share the same variable and I'm trying to store the boolean variable for only one drawer. I know I can give to each drawer a different global variable, but managing 20 or more variables for drawers will be a pain to organize. So I thought I could somehow use private variables and store info there, but I couldn't find how I could do it.

I also thought that the local variables could somehow be private, but they add the same result as the global ones.  

Maybe I'm doing something wrong, but my conclusion was that Adventure Creator doesn't feature private variables.

Comments

  • Not currently, though that does give me some ideas that I will look into.  Please give me some time to think about how something like this could be added as a feature.
  • For the record, it's much easier to check the drawer's current moveable track position and open/close it from there (assuming you're using moveables on tracks, that is). I.e.: If it's less than 50% open, then open it; if it's more than 50% open, then close it. This can be parameterised in an Action List asset.
  • edited August 2016
    I'm not sure if @JPinho is using Tracks for the drawers, but @GeometriX does have a point - a custom Action could check for the drawer's local position (relative to a parent object) and determine it's opened/closed state accordingly.

    A tutorial on custom Actions, if that's something that interests you, can be found here.  A custom "checking" Action is a little more complicated - it must derive from ActionCheck, and must include an overriding CheckCondition function which returns the final result as a boolean.  The simplest such Action, Object: Check visibility, can be used as an example in ActionVisibleCheck.cs.  We can give more help if you're not experienced with C# coding, but I'll wait to hear if that interests you first.

    Back to the issue of private variables - an asset cannot access local variables, as they live in scenes while assets do not.  The same would therefore have to be true of private variables, which to my mind would come as a script you could attach to an object, and then use that to define a separate set of variables much like you do already in the Variables Manager.  But the hassle of creating e.g. 20 such scripts would be equal if not more so than creating 20 global/local variables, so I'm not sure of the benefits there.

    What I would recommend, if you don't want to go down the custom Action route, is that you rely on scene-based Cutscenes rather than ActionList assets.  This will allow you to reference Local variables, rather than Global variables, which will at least mean you don't have them cluttering up your Variables Manager in other scenes.  You can convert an existing ActionList asset into a Cutscene via the cog icon to the top-right of its Inspector.
  • Thanks a lot for the thorough reply. I'm still inexperienced with Adventure Creator so I'm not very familiar with some of the terminology both you and GeometriX are using. I'll be sure to look into movables on tracks and cutscenes.
  • No problem, we're here if you have any related questions.  Moveable tracks are related to the physics system showcased in the Physics demo.  Cutscenes are simply scene-based ActionLists that have the added advantage of being able to access local variables.
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.