Forum rules - please read before posting.

Unity's Game Foundation Inventory System with AC?

I just purchased and downloaded AC today. I am wondering if there's a way to integrate unity's newly released game foundation inventory system into AC? Since it is still in preview stage there's not many tutorials on how to use it.
You can read about it here: https://docs.unity3d.com/Packages/com.unity.game-foundation@0.8/manual/Tutorials/06-StaticProperties.html
It basically sets up a whole inventory system for you, with currency, transaction systems. It would be great to know how to use this in my game along with AC!

Comments

  • edited May 2021

    Welcome to the community, @AdventureShitzu.

    I'd advise caution with using something that's still in preview, but I should think the two would be able to work separately in the same game. However, in a realistic scenario you'd probably need the two to be tied together, as you need to consider how items from another system are stored in AC save game files, or used with AC Hotspots, etc. How you go about something like this really depends on the specific needs you have for such an integration - unfortunately, there's no "set way" to approach such things.

    If you wanted to, e.g. sync your AC inventory up with that of a separate system, you could hook into custom events that allow you to update the other system when AC items or added or removed:

    using AC;
    using UnityEngine;
    using UnityEngine.GameFoundation;
    using UnityEngine.GameFoundation.DefaultLayers;
    using UnityEngine.Promise;
    
    public class InventoryEventExample : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnInventoryAdd += OnInventoryAdd;
        }
    
        private void OnDisable ()
        {
            EventManager.OnInventoryAdd -= OnInventoryAdd;
        }
    
        private void OnInventoryAdd (InvItem invItem, int value)
        {
            Debug.Log ("Added: " + invItem.label);
            string definitionKey = invItem.label;
            InventoryItemDefinition definition = GameFoundationSdk.catalog.Find<InventoryItemDefinition> (definitionKey);
            InventoryItem item = GameFoundationSdk.inventory.CreateItem(definition);
        }
    
    }
    

    You can read more about manipulating items through script in the Manual's "Inventory scripting" chapter.

    If you're mainly looking to create a shop system, though, do know that an example package for this can be found on the Downloads page. AC inventory items can both be categorised, and given additional properties, in the Inventory Manager. This package demonstrates how such information can be used by simple scripting to customise inventory behaviour to provide a trading mechanic.

    I would, however, recommend first familiarising yourself with how AC works "by itself". Whether you want to sync it up with a separate system, or extend in a similar way, it's important to first know its capabilities work out-of-the-box.

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.