Forum rules - please read before posting.

Dropping Multiple Items from Inventory into Scene

Hello,

I am having a bit of trouble picking up and adding a Scene Item into my Inventory. It is working correctly on single items, but am running into an issue on items that are supposed to stack/there's multiples of.

I followed this guide thinking it would help me: https://www.adventurecreator.org/tutorials/dropping-items

So I am most likely doing something wrong.

Below I will attach all of the ActionLists involved with this and a video example of what is happening.

There is also a custom script (that I will attach) that gets the Inventory item that is being hovered over with the mouse, this works as intended with everything else as the correct item is always being dropped but am still including it anyway.

Basically I have an Inventory item that are Floppy Disks, which you can carry multiple of. I am dropping them from my inventory, however when I try to pick them back up, instead of picking up the object I am clicking on, it automatically picks up the first Floppy Disk I dropped. So for instance, I drop a Disk in a corner of the room, go to another corner and drop another. If I pick up the last one that I dropped, instead of the Disk I am selecting disappearing from the scene, the first Disk from across the room gets picked up.

Video of what is happening: https://streamable.com/wukrul

Pictures of related ActionLists: https://imgur.com/a/inventory-info-pI8JTpf

Unity version: 2021.3.2f1
AC version: 1.80.1

Any help would be much appreciated! I am sure it has to do with the Constant IDs, but each dropped object would need their transforms remembered in case the player saves - I would like the items dropped to stay where they are. Thank you and would be happy to provide more information!

Comments

  • Thanks for the details. Yes, it's likely Constant ID-related.

    The most immediate likely cause I'm seeing is that you're manually setting the ID for your Remember Scene Item component - meaning each instance in the scene will have the same value.

    Switching this back to Automatic should cause each instance to have a unique ID, and then be correctly referenced when being picked up.

  • Hey Chris, thank you for the response!

    So I did change it to Automatic but the same problem did persist. However, I did notice that each instance of the Floppy that is dropped has the same exact ID number instead of each instance being unique.

    With that information does it seem like I missed a step somewhere along the line?

    Here is a link that shows it set to automatic in the prefab, and also a couple photos each game showing the instances sharing the same unique ID number: https://imgur.com/a/DNqixH1

    Am I right in thinking that upon spawning in the world it is supposed to be unique to the instance, or is there a step I'm missing to make it so?

    Thank you again!

  • upon spawning in the world it is supposed to be unique to the instance,

    That's right - though, going back a step, it should be that the Constant ID/Remember components all have an ID value of 0 when viewed in the prefab, so long as Retain in prefab? is (correctly) checked.

    Is the first screenshot is from the prefab as viewed in the Project window, or from Unity's prefab mode?

    Try resetting these components via their cog icons in the Inspector - that may get them to reset back to zero.

  • Thank you Chris! Resetting the components to 0 did it! I must've missed that a prefab had to be set to 0 to generate a random ID on spawning into the scene - I didn't think it mattered so my mistake.

    The first image was taken in the project window so doing what you said immediately fixed the problem, and all instances are spawning with a unique ID.

    Thanks again and sorry it was over something so trivial. I'm glad I have this info for the future now, spawning in items is a lot easier than I thought now. Have a great weekend!

  • I'm not so sure it was a mistake on your part - the default behaviour should be that prefabs use "0" unless explicitly set to do otherwise.

    If this occurs again, can you let me know with steps to recreate?

  • Yes next time I'm in the project I will try it out and if it does that I'll let you know here!

  • So the reason the prefab's ConstantID wasn't being set to 0 automatically was I built my object in the scene and assigned all components in scene (so Remember Hotspot, Transform, etc) and that of course automatically sets an ID. Then when I prefabbed the object by dragging it into the project window, it keeps the prior ID instead of setting to 0.

    Seems reasonable to me and not a bug. If I'd known that setting a prefab's ID to 0 would automatically populate a unique ID at runtime I wouldn't have had any issues. Hope that all makes sense!

  • Certainly - thanks for the follow-up.

  • edited July 2024

    Hello, I am having a bit of an issue but decided to follow up with it here as so it would be easier to follow with my setup above.

    I am dropping an object from my inventory that has a child Trigger on it. On the child's Trigger I have a 'Remember Trigger' component set to 'Off'.

    However, when I drop the item, the trigger is activated as normal instead of ignored. I tested that when the exact same item is already in the scene, it won't trigger as intended. However, whenever it is instantiated, it seems to ignore the 'Off' trigger state.

    For simplicity's sake: the actionlist that is being ran when this Trigger is 'triggered' is just a simple Dialogue interaction.

    So, whenever this trigger is being instantiated, it is not in the 'Off' position as intended in the Prefab and is being 'triggered'. However, if the item already lives in the scene, the trigger does not get 'triggered'.

    Is this known and intended behavior?

    Photos of the Prefab's inspector: https://imgur.com/a/rVpfj21

  • I'll need to recreate the issue on my end, but your provided details should be enough - thanks, I'll look into it.

  • Thank you! Apologies if it's just something on my end, but I had been trying to figure it out for a good bit and just wanted to make sure it wasn't something along the lines of it being unintended behavior with the actions themselves.

  • No problem - it's less a bug, I'd say, and more of an oversight. You're quite right to expect that the start state should be respected upon spawning.

    I'll see this addressed as part of v1.81.5.

  • Thank you very much! I came up with a solution for now but I'm glad it'll work that way from now on. Thanks for looking into it!

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.