Forum rules - please read before posting.

Looking up Persistent Container via code

Hello everyone,

I'm playing around with idea of using persistent container (https://adventure-creator.fandom.com/wiki/Creating_a_global_Container) as a list for saving some values for my game. In this case I'm trying to determine which NPCs are dead.

I have created a container that accepts only Item Category Persons (and was assigned id:0), and item of said Category named npc_joe. Now I would like to tap into that container via code to check on any scene if that item is located within that container.

The base idea is this:
https://imgur.com/a/yO0JvLv

And current test implementation is:
https://imgur.com/a/Lcws7S6

For now, I'm manually assigning Container which is present in same scene, but once this won't be possible in scenes where it is not yet present.

I tried digging through manual and documentation, but I can't seem to be able to find how to make it find Container id:0. Is this even possible?

Thanks in advance

Comments

  • edited July 2023

    As long as the container game object also has a Remember component (and thus a constant ID assigned to it), you should be able to run AC actions that refer to it in any scene. To set up a check in a different scene, you could create a prefab, drop it into the scene, assign it to the action you want, and then delete the object in the scene.

    Either way, I'm not sure I understand why you're doing this with containers. Imho it'd be easier to rely on component 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.