I am setting up treasure chests that can open their lids.
However, there are some issues, and I would like to ask for advice.

1)
I followed the tutorial for trap doors in the dungeon from the 3D Playground to configure the keys.
However, when there are multiple treasure chests, opening one causes the other chests to change to an open state as well, which is problematic.
I believe this issue occurs because the variables are shared among all chests.
I tried setting unique keys for each chest locally, but it didn't work.
Is there a good method to assign unique variables to each treasure chest individually in this case?

2)
I have set the item collector to activate when the treasure chest transitions to its open state.
However, after the item is collected, the player's control does not switch back.
If I block the controls, the player remains unable to move even after obtaining the item.
How can this issue be resolved?
  • 1) If you have multiple chests, each needs to have it's own unique variable, e.g. chest_1, chest_2, etc.
    You can somewhat manage this for multiple scenes by using Object ID variable source with the scene name being used as object ID, otherwise each variable key has to be unique for the whole game (e.g. scene_1_chest_1).

    2) Are you using the Start Schematic of the item collector for this or some custom code?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 15
    Thank you for all your support.

    1)
    In a single scene, there are multiple treasure chests.
    As such, following the tutorial by setting the object ID to the scene name causes all the treasure chests in the same scene to open simultaneously.
    Therefore, I tried using local variables.
    However, on further thought, as long as the script is the same, all the objects to which the script is attached will perform the same actions, making local variables potentially meaningless.
    I assigned an ID to each treasure chest script, but all the treasure chest lids ended up opening simultaneously.

    2)
    I'm using Dotween or Custom code.
    The Start Schematic of the item collector is not used.
    This results in the player becoming unable to move, as mentioned in the question.
    Post edited by lonewolf_cat on
  • edited March 15
    Even when the Item Collector component is disabled, the interaction prompt appears when approaching, and items can still be obtained.
    I tried enabling the Item Collector or its attached child object upon opening the treasure chest, but it is still possible to acquire the items before the chest is opened.
    Post edited by lonewolf_cat on
  • edited March 16
    The problem where the player couldn’t move has been resolved.
    It was caused by having multiple item collectors with the same ID.

    I've been testing various approaches through trial and error.
    Even if I make the variables global, it doesn’t help because the Schematics are shared, meaning the variables become shared as well.
    It looks like I’ll have to create a separate Schematic for each treasure chest.

    However, I have an additional question:
    3)No matter how I configure it, the interactions for all machines—including the item collectors—react to the Accept (Enter) key.
    Even when I disable the Key Press option, they still respond.
    Why is this happening?

    4)Since I determined that it is difficult to control the state of the treasure chest using variables as described above, I’ve decided to control its state based on whether the key is present or not. However, even when I set it up in the Game Object Manager as shown in the picture, it doesn’t work properly. The object (treasure chest) disappears whether or not the key is held. Is my configuration incorrect?
    image
    Post edited by lonewolf_cat on
  • lonewolf_cat said: It looks like I’ll have to create a separate Schematic for each treasure chest.
    If the variables are changed in the schematic, yes. Otherwise the schematic always changes the same variable.

    3) This is most likely the Interact start type. This is started when using the interact key defined in Base/Control > Game Controls > Interaction Settings while an interaction is within the player's Interaction Controller.

    The Key Press start type is used whenever the defined key is pressed, independent of the interaction being within the player's interaction controller trigger.

    4) I'd need to see the whole setup to give an advice here.
    Generally, using game object managers should have the managers and the game objects they manage be separate game objects (or e.g. a game object manager managing a child object of itself).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you for your reply.

    It seems that my intention was not conveyed to you because I used confusing terminology. My apologies.

    Here, "key" means "a key to open the treasure chest."

    In other words, the object manager wants to switch objects based on whether or not the key to open the treasure chest is present, instead of using variables.
    However, in reality, the treasure chest disappears regardless of whether or not the key is present, and neither state is achieved.
  • Still, I need to see the whole setup to give advice - I can see one condition (which seems correct), but there is a nother game object manager component, and I don't know if they both use the same game object, etc.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Alright, I'll attach pictures of both settings in the Game Object Manager.
    The method involves simply changing the inventory(treasure key) count to either 0 or 1. However, as mentioned above, regardless of whether the treasure key is in possession or not, neither condition in the Game Object Manager applies, and both objects end up disappearing.

    image

    image
  • Instead of checking for quantity 0 being in inventory, check for quantity 1 not being in inventory, i.e. disable In Inventory setting.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I tried disabling the "In Inventory" and tested both patterns with values 0 and 1, but the treasure chest still did not appear.
    Even after obtaining the key item, the treasure chest does not show up.
    Just in case, I changed the "Status Needed" item to "one," but the situation still remains the same.
    I’m starting to think there might be another cause.
    I will investigate further.
  • Did a quick test with a similar setup (no item collector involved, though) and that worked fine.
    Do your 2 chest child objects have any other conditions (e.g. from machine components or item collector) on them that could disable them?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • After trying various methods, the treasure chest still does not appear.
    I also tried deleting the child objects of the treasure chest, but the result was the same.
    However, when I changed the Game Object from "user" to "Player," the result was as desired.

    Game Object: Player
    Key Item: 1
    Inventory: Disabled
    Get Key Item

    Game Object: Player
    Key Item: 1
    Inventory: Enabled
    This is what I should have done.
    Additionally, even when holding two keys, the state of the treasure chest transitioned in the same way.
  • Ah, sorry - I didn't notice that in your screenshots.
    Yes, for such a setup you need to use the Player game object to actually check the player's status. The User is context-based, e.g. here it'd be the game object the manager is attached to.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.