Forum rules - please read before posting.

Dropping Inventory Items into Scene (First Person 3D)

Hello,

I'm having a bit of trouble dropping inventory objects from the inventory into the scene. I followed this tutorial: https://www.adventurecreator.org/tutorials/dropping-items

And I understand how it works, but I think my problem is stemming from my unique interaction methods in the game.

It is a first person 3D game, Interaction method is Context Sensitive, and I am attempting to have the item drop when:
-After it is selected in the inventory
-You can press Right Click on the mouse to 'drop' the item (just right clicking will do it, not when over a hotspot)

I'm having trouble getting my actionlist to run when right clicking.

Here are my settings as well as the inventory item in question and the Actionlist I am attempting to run:
https://imgur.com/a/B1RztoW

-I thought I could get around this within the Inventory Settings: Right click active item: Examines Item
-And then on that Inventory Items 'Examine' Interaction, assigning the ActionList I wish to run
-But currently that is not working when I right click when the Item is selected, here is a visual of what is currently happening, the ActionList doesn't run: https://streamable.com/0qa9n2

-I do have the cursor snap to center on right clicking, is that a problem? Basically I believe my question is: how can I get an Inventory Item's Examine ActionList to run on Right Click

Thank you for any help!

Comments

  • Try using an Active Input - which is a way of running an ActionList when a given input is detected. The Active Inputs editor is accessed from the top toolbar.

    You might find, though, that you need more control over when it can be run - e.g. when not over a Menu, or a Hotspot. For this, you can use scripting to manually enable/disable the Active Input - but give it a go without, see if it's along the right lines, and we'll take things from there.

  • Thank you for the help!

    Yes, the ActionList does run correctly after assigning a 'Drop' Active Input (the 'G' key for this purpose)

    So then, thinking out loud what I would need to do to make this work completely the way I was intending would be to:

    -Have the ActionList run when pressing the Left Mouse Button (I incorrectly said Right Click in the OG post)
    -Drop the currently held Inventory Item
    -Only do this when not on a Hotspot (being over a Menu would be fine)

    So my thinking then would be:
    -Have the ActionList run a custom script to get and return the Inventory item being held so I can pass in what Inventory Item to drop (using ActionList parameters I would think?)

    -Have a way to check when over a Hotspot or not to enable/disable the ActionList like you mentioned.

    Thank you for getting me on the right track! I'll take a look at the custom scripting guides and see what exactly I have at my disposal here, I've done a few custom scripts before using AC but haven't with anything Inventory or Hotspot related.

  • Thanks for clarifying. This sounds like the right approach.

    Have the ActionList run a custom script to get and return the Inventory item being held so I can pass in what Inventory Item to drop (using ActionList parameters I would think?)

    A script isn't necessary for here, parameters should be enough.

    Create an Inventory Item parameter, and begin your ActionList with an Inventory: Check selected Action. Check for None Selected, ending the list if this is True.

    Then, use the Send to parameter field to update your parameter with the selected item, if False.

    Have a way to check when over a Hotspot or not to enable/disable the ActionList like you mentioned.

    I'd like for to similarly be doable using parameters, but for now you can use this script to enable/disable the Active Input:

    using AC;
    using UnityEngine;
    
    public class AutoSetActiveInput : MonoBehaviour
    {
    
        void Update ()
        {
            bool allowInput = KickStarter.playerInteraction.GetActiveHotspot () == null;
            KickStarter.settingsManager.activeInputs[0].IsEnabled = allowInput;
        }
    
    }
    

    (Replacing "0" with the index of the Active Input to affect)

  • Sorry for the delayed response, hadn't had a chance to touch this project until today!

    Using the parameters for dropping the Inventory objects work like a charm. I can pick up any object and drop the correct one using them, thank you!

    I ran into some initial design flaws on my end, so I had to change around how items work a bit but as of right now I've got it all working as I need. I didn't need the custom script, however I did tuck it away in case I need to break it back out, thank you for that!

    In case I come back to this subject, here is how it is now if anyone runs into the same problem:

    -Left click selects an inventory item

    -'G' key drops the selected inventory item (using the method above with parameters)

    -Right click runs the selected inventory item's "Examine" ActionList assigned in the Inventory Manager, however for my purpose these are actually "using" the specific item's function. For instance:

    The lighter inventory object creates a light source when used, this is functionality that does not need a Hotspot to happen, so in the Settings Manager I assigned "Right click" to "Examine" the selected item, running the assigned ActionList in the Inventory Manager.

    If there is an easier or cleaner way anyone feel free to chime in! Thank you again, Chris!

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.