Locked Chest Problems

nitrox32

Member
I'm using UCC and am having some problems with a locked chest. I am using the Locked Chest prefab from the UIS demo scene (not the integration scene). There are a number of problems. First, the when Nolan approaches the the chest the text message displays, the player input doesn't stop like in the the UIS demo scene. Second, the display messages are reversed. I created a text panel just like in the demo scene. I didn't use the UI designer for this. The On Try Open No Key() and On try Open Has Key() are correct. The lock and key system work when the key is and isn't in the inventory. It's only the player input and message reversed that is the problem.
 
I'm sorry I'm not sure what you mean by message reversed? Do you mean it is visually flipped, or that the message content are swapped? If it is the latter check the inspector, that's where the message is defined.

As for the input not working, I'm not sure why that would be the case. Make sure the Interable component on the chest is set to interact on input and not on trigger enter, as well as the Interactor component on the character. Make sure the LayerMask on the Interactable is set to detect the character layer.
 
I'm sorry I'm not sure what you mean by message reversed? Do you mean it is visually flipped, or that the message content are swapped? If it is the latter check the inspector, that's where the message is defined.

As for the input not working, I'm not sure why that would be the case. Make sure the Interable component on the chest is set to interact on input and not on trigger enter, as well as the Interactor component on the character. Make sure the LayerMask on the Interactable is set to detect the character layer.
 
Sorry I wasn't clear. The message content is swapped. The message that is displayed when the player doesn't have the key is the one that is in the Text Has Key. And when the player has the key the Text If No Key is displayed. Do you mean the Inventory Interactor on the player? As far as the Interactable component on the chest, do you mean the Auto Interact should not be checked?
Capture.PNGCapture.PNG
 
You are right something is wrong with the Locked chest. I just tested it in the demo scene and it is acting weird. I wonder how I didn't catch this before.

So as you said the displayed message is wrong, so here is the fix. Change this code within the ChestLockedMessage.cs file:

Code:
public class ChestLockedMessage : MonoBehaviour
{
    [Tooltip("The text that will be displayed when the interactor does not have the key.")]
    [SerializeField] protected string m_TextIfNoKey;
    [Tooltip("The text that will be displayed when the interactor does have the key.")]
    [SerializeField] protected string m_TextHasKey;
    [Tooltip("The amount of second the text will hte displayed for.")]
    [SerializeField] protected float m_TextDisplayTime;
    [Tooltip("The text panel component.")]
    [SerializeField] protected TextPanel m_TextPanel;
    /// <summary>
    /// Initialize.
    /// </summary>
    private void Awake()
    {
        if (m_TextPanel == null) {
            m_TextPanel = FindObjectOfType<TextPanel>();
        }
    }
    /// <summary>
    /// No key to open.
    /// </summary>
    public void OnNoKey()
    {
        if (m_TextPanel != null) {
            m_TextPanel.DisplayText(m_TextIfNoKey, m_TextDisplayTime);
        }
    }
    /// <summary>
    /// Has key to open.
    /// </summary>
    public void HasKey()
    {
        if (m_TextPanel != null) {
            m_TextPanel.DisplayText(m_TextHasKey, m_TextDisplayTime);
        }
    }
}

The other bug, specific to the demo, was that the TextPanel component had lost the reference to the Text component and therefore it was always displaying the same message over and over again.

As for your input issue, if auto interact is on, then the character will automatically interact on trigger instead of waiting for you to press a button. The screenshots you sent look good, so I'm not sure what the issue could be. Could you perhaps send me a video (use streamable.com) of your in action such that I can have better idea of what is going on?
 
Thanks, the corrected code fixed the message issue. Everything seems to be working correctly now. The only thing I would like to do is have the player input stop when the have/does not have key message is displayed. Is that something that can be done out of the box?
 
I see... Unfortunatly there isn't an option like that built-in. But I'll add it in for you.

Please find attached a new script (not tested, so let me know if if doesn't work). It allows you to enable/disable inventory input when the component with that script is enabled/disabled.
Since the TextPanel component enables/disables a gameaobject, you can simply add this new script on that gameobject and set it such that it disables the input while it is enabled.

This script is part of the UltimateInventorySystem/Scripts/Input folder.
 

Attachments

  • EnableDisableInventoryInput.cs
    2.8 KB · Views: 2
Yep, the script works. Thanks. The only thing is that after the chest opens and the inventory is displayed, input returns after the message goes away. I see this is what the script is designed to do. However, it would be great to have the input return only after the items have been taken and the Chest Inventory panel goes away. Kinda like when a normal chest opens.
 
Ah sorry I misunderstood your request. You wish the input the disable while the Chest Window is opened and not while the text is being displayed.

In that case what you want is make sure the to setup the Display Panel Manager such that it only enables the input while the gameplay panel is selected. Then simply make sure the chest window DisplayPanel has the "is selectable" option ticked on.

This way while the chest window is opened the gamplay panel will be deselected which will disable input and when the chest window closes the gameplay panel will be selected again and the input will be enabled again.

Check the UI section on this page (it's around the end)

Check and this place too:
 
Sorry, I still can't get the Locked chest UI to stop the player input when the chest UI panel opens. It stops when a normal chest opens.
 

Attachments

  • Capture.PNG
    Capture.PNG
    37.2 KB · Views: 3
  • Capture1.PNG
    Capture1.PNG
    43.1 KB · Views: 3
  • Capture2.PNG
    Capture2.PNG
    43.7 KB · Views: 3
I replicated your setup in the demo scene and it works as expected for me... I really don't know why it doesn't for you.

The part that disables the input is the DisplayPanelManager when the ChestMenu is active. Whether it is opened by the Chest or the LockedChest should be irelevant because they should both be opening the same ChestMenu.
Can you confirm you only have a single ChestMenu in your scene?
Can you check your Menu hierachy when opening the chests. Is there any difference when opening one or the other. For me it looks like this:
1642410646512.png

If you can replicate the issue from the demo scene with specific steps do let me know and I'll try those, because right now I can't seem to replicate it in the demo scene
 
Yes I do have more than one chest in the scene. When I removed all of the chests in the scene the player's input was disabled as it should. After adding more chests things seem to be ok. I'm not sure what happened.
 
Top