Forum rules - please read before posting.

Component variables, prefabs, and actionlists

edited November 2022 in Technical Q&A

To avoid having hundreds of global variables that are hard to organise, I use a lot of component variables as well. To make them work across scenes, I add them to child objects under the player prefab. This is my workflow:

  • Keep an inactive instance of the player prefab in the scene.
  • When necessary, activate it, add/modify variables, apply to prefab, and make it inactive again.
  • Likewise, when I need to check and/or set variables in an actionlist, I will activate the player instance temporarily so that I can pick the appropriate variable. When the prefab is deactivated, the actions will correctly list the variable component's ConstantID.

This seems to work properly 90% of the time. The issue is that sometimes it doesn't, and I can't figure out what exactly causes this. When the problem happens, the actions that are supposed to set/check the component variables will stop working work (I'm not sure if they default to a certain value, or if they are skipped altogether). This doesn't only happen to actions I've just created: sometimes an action I haven't touched in ages simply breaks. I can't guarante I didn't change other parts of the actionlist, but I'm pretty sure I didn't touch the relevant actions.

To fix this, I simply open the offending actionlist. I also usually expand the action if it is collapsed (not sure if this step is necessary or not). I also toggle the player prefab instance on and off for good measure. This always fixes the bug. It's pretty straightforward.

This is a relatively rare problem (it will happen maybe once a week, working on the game full time), but it's really bad because I don't know there is an issue until I run into it playing the game, and I don't know what it is that I'm doing that breaks it. I'm afraid this will create a QA nightmare later on when I can never be sure everything is working properly unless I recheck every single actionlist in the game every time I make a new change/fix an unrelated bug.

Chris, do you know what the issue might be here? And do you know why opening the actionlist fixes it? There must be something breaking the connection between the ConstantID recorded and the component, and I assume that opening the actionlist is refreshing some data and fixing this. If this is the case, is there perhaps a way to refresh all actionlists in a scene or in a project (in the case of actionlist prefabs) so that we can fix any possible errors automatically before creating a build?

Comments

  • edited December 2022

    Is this when dealing with scene-based ActionLists, or ActionList assets?

    When an Action is viewed, it will auto-set its Constant ID value records for fields that it deems necessary. If this value isn't correct, viewing the Action will correct it.

    When using scene-based Actions to control scene-based objects, however, CID values aren't recorded as they aren't necessary. AC will check an object's presence in the scene to decide this. If your Player's CID value isn't changing, it may be the enabling/disabling of the scene instance that's confusing it.

    What you'd be better off doing is to remove the scene instance, and assign the original prefab into your Actions directly. Actions will always record a CID value in this scenario, and will look for the scene instance when run.

    It may be possible to write a script that runs the ShowGUI function for all Actions in all ActionLists in all scenes, but I'd recommend trying the above workflow instead.

    To get a breakdown of all Actions that reference your scene instance, click the cog icon in its Constant ID component and click Find local references.

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.