Forum rules - please read before posting.

Multiple inventory items on same hotspot

edited March 2021 in Technical Q&A

When using the inventory Interactions I select specific items from the inventory to work on my hotspot - what if I want to make a range of multiple items to be used on the the same hotspot?
Say I have a magic bowl where items can be dragged into based on a recipe.
The Inventory will have 5 items and only 3 of these are correct.
I want to make a check random number based that will select some pre-defined items that are being added to the inventory.
I have been able to do this with triggers - but not sure how I can "overwrite" the Inventory Interactions so instead of using a specific items I need to select I can refer to an actionlist.
Any direction would be much appreciated
Best, Dan

Comments

  • I have made a spawnObject Actionlist, that uses uses a random check and from those unlock a menu with inventory elements. This is being triggered when game starts.
    On the hotspot I have used Inventory Interactions and made an interaction script and set a variable set to true.
    Back in my spawnObject at the end I do a variable check to see if my inventory interactions are true - and if they are dialogue play.
    The hotspot triggers play all the particles and stuff when the inventory item is being dragged to the hotspot - but my bools are not showing the speech when the check is true - so I guess I have placed the check the wrong place.
    Where would it make sense to play the logic so it runs in the background?

    If I have say 2 items that need to be dragged into the hotspot in order to "solve" it, I have made a check on the first object, if true, then skip to next object and check and if true then show dialogue. If not true, it goes back to check again.
    Does it make a difference if it check the first on only in order to continue to the next, even though the player might drop the second one first?
    Since both have to set to true before, I thought it could use any to start with before continuing.

    (The above example is like a "recipe" - drop to correct items on the hotspot.
    I want to make many of these - so parameters will be needed - however say items 1 in inventory will be correct in one case and wrong in another - so I guess the solution is to have a unique hotspot for each "recipe"?(so the Inventory Interactions can be unique for each recipe)

  • I'm sorry, but I'm really not clear on what you're looking to do. Can you provide screenshots, or mockups, to illustrate your intent?

    From what I understand, you're mainly looking for a way to know if the Player has added all the correct ingredients? That is, used the correct items on a Hotspot.

    Is the Player only ever carrying one instance of each "ingredient" item? If so, you could bypass the check for which specific item has been added (and having a separate variable to keep track of each item), and just use a "score" integer. If the player adds a correct item, the score increases, and the score is then checked to see if it's high enough to "win".

    Don't worry about making use of parameters for the moment - let's just focus on getting the logic for a single instance of the puzzle working first. It may even be that a script is more appropriate, but I'll need a more clear description of the situation, starting from the very basics of how your game is played.

  • edited March 2021

    Thanks Chris!
    Yes, that is correct, in regards to looking for a way to know if the player has added all the correct ingredients on the hotspot.
    The idea of of the game is like a machine where you add item a+b (or c, d etc also to make it more complicated) and then there is an output(win or loose)
    Makes a lot of sense to just use a "score" and have it checked.
    Right now I have solved the "check" by having a button that runs it, meaning after items have been dragged and dropped onto the hotspot, then a button is pressed.
    Instead of having a button pressed to run the check - can it run in the background so it just runs the check in the background and then "wins" when the score has been reached? I have tried to add the check in onVar but I recall doing it once, but not sure in what cutscene I did it so it just ran the check in the background and checked while running.

    Thank you so much.

  • How is the score-check being run? Via an ActionList asset?

    You can end your various Hotspot interactions with an ActionList: Run command to run the list once it's done everything else.

    You can also use the OnVariableChange custom event to automatically run the list whenever the variable's value is updated:

    using UnityEngine;
    using System.Collections;
    using AC;
    
    public class VariableEventExample : MonoBehaviour
    {
    
        public ActionListAsset actionListOnUpdateScore;
    
        private void OnEnable () { EventManager.OnVariableChange += OnVariableChange; }
        private void OnDisable () { EventManager.OnVariableChange -= OnVariableChange; }
    
        private void OnVariableChange (GVar variable)
        {
            if (variable.label == "Score")
            {
                actionListOnUpdateScore.Interact ();
            }
        }
    }
    
  • edited April 2021

    Yes, the check is done by a separate ActionList.
    It's for a game where you do magic - drop items into a hotspot and it gets "transformed" into something. Items can be used across different recipes.

    The integrated crafting system might seem like something that makes sense to use, since items can be used to make several "recipes".
    Is it possible to drop the items onto a single hotspot instead of "inventory slots" ?
    I tried "scaling" the slots to see if I can stack them all in one, so it would fit a "hotspot", but I doesn't work.
    Similar to my hotspot solution, so the player just dumps the items(multiple) on the hotspot (and then the I can do check and execute the create new item automatically.

    Hope everyone had a great easter!
    Cheers, Dan

  • Is it possible to drop the items onto a single hotspot instead of "inventory slots" ?

    Through script, yes. Try this: attach it to your Hotspot and add an "Unhandled Inventory" interaction:

    using UnityEngine;
    using AC;
    
    public class HotspotRecipe : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnHotspotInteract += OnInteract; }
        private void OnDisable () { EventManager.OnHotspotInteract -= OnInteract; }
    
        private void OnInteract (Hotspot hotspot, Button button)
        {
            if (hotspot == GetComponent <Hotspot>() && hotspot.GetButtonInteractionType (button) == HotspotInteractionType.UnhandledInventory)
            {
                if (InvInstance.IsValid (KickStarter.runtimeInventory.LastSelectedInstance) && KickStarter.runtimeInventory.PlayerInvCollection.Contains (KickStarter.runtimeInventory.LastSelectedInstance))
                {
                    KickStarter.runtimeInventory.CraftingInvCollection.AddToEnd (KickStarter.runtimeInventory.LastSelectedInstance);
                    KickStarter.runtimeInventory.SetNull ();
                    PlayerMenus.ResetInventoryBoxes ();
                }
            }
        }
    
    }
    

    When you attempt use an item on the Hotspot, that should cause the item to be added as an ingredient. For testing, keep the crafting menu open so that you can check things are being added in.

  • edited April 2021

    Chris - THANK you! This solved it - and by adding a nice particle effect it just looks gorgeous when things are being added! and even still keeping the crafting menu visible, its possible to use the "ingredient" slots as "labels" similar to HayDay etc that has small labels below the "machine" items have been added to.
    Maybe others can use this as-well.

    I love your wonderful asset and very addictive playing with and coming up with all sorts of ideas.
    Thank you for being so helpful.

    Best, Dan

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.