Forum rules - please read before posting.

Suggestion: asset variables

Global variables are great to keep track of things across scenes, but even using "/" to nest them into menus, I find that's not enough to keep them organised and tidy. For that reason, I've long used many different component variables in a prefab that I then instantiate under DontDestroyOnLoad. This works well, mostly. The issue with this approach is that then I need to drop a copy of the prefab into the scene to be able to access/edit the variables through action lists (and this sometimes, although rarely, breaks the 'connection' between the action and the object, even though the ConstantID is the same, and this isn't fixed until I reopen and close the actionlist in the scene).

So I was thinking: do you think it'd be be feasible/worth it to have a variable asset to keep component variables accessible even when not present in the scene? Basically, component variables would have a "convert to asset" button, which would turn the object into an asset with the same constant ID, and the variables would be immediately available to scene actionlists even when there was no instance of that constant ID in the scene.

Of course, this wouldn't replace component variables. One of the most useful things about them is that you can attach them to a game object and then have a script that can read/modify them - super useful to keep the stats of spawned mobs, for example. But when you're using them as a more manageable alternative to global variables, an asset would really be the best option!

Comments

  • Interesting suggestion, thanks for the detailed explanation of your use-case.

    It's a good idea in principle, though I do imagine adding a fourth variable source would add confusion to new users. There's also the issue of saving/loading such data, as without a direct reference within a scene/Manager, there's potential for such variables to miss out on the save process.

    Regarding your current approach: it should be quite possible to assign the prefab with the Variables component directly - no need to add it to the scene to configure the Actions. So long as the prefab is present in the scene at runtime (which can be automated via the "Scene / Begin game" event), the scene instance should be the one referenced at runtime.

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.