Branch Node returns both true and false at the same time - why could this be?

Hi all,

I’m new to Unreal and trying out some basic gameplay mechanics. I have implemented an inventory system (following a tutorial by Ryan Laley) which contains a query function to check if the player has a particular item in their inventory. So far, this has worked great for me.

Now I created a blueprint for a door for which you can define a “key item” that is required to open it. I am using the query function for:

  1. opening the door upon interaction and
  2. displaying a contextual message widget, when looking at the door.

Opening the door works fine: if I set a key item, it only opens once I have the item (at the specified quantity) in my inventory. However, the same logic produces a weird error when trying to display a contextual widget: it seems to be rapidly alternating between true and false, thereby displaying two messages at the same time.

The logic seems pretty straightforward to me, so I have no idea why this is happening; especially, since I’ve been using the same logic on a different actor, where it manages to display the contextual messages just fine.

Not sure if it’s an issue with the inventory system, or if I am missing something obvious here.

Any tips and ideas are appreciated.

Hey @Ontologist! Welcome to the forums!

Could you get us the code where your “Look At” is being called from?

It’s possible that if you are doing a ForEach or ForLoop that this is running rapidly and you actually WANT this to happen.

What I’m getting at, I suppose, is we could use more context! :slight_smile:
Also, you can post the link to Ryan Laley’s video and I can look at it a bit. I’m pretty sure I did this one when I was starting out.

Hey, thanks for your kind reply! :slight_smile:

The “Look At” function is part of an interaction interface.
grafik

The blueprint component for the inventory system contains the code for a line trace and calling the message widget.

There is a forEachLoop on the QueryInventory Function going through each inventory slot to count the specified item’s quantity.

Btw, here is the other actor for which I’ve already used something very similar, without this issue (a remote requiring two batteries).
Edit: As a test, I even copied the exact same code from the remote actor to my door - still leading to the issue on the door, but not the remote. :upside_down_face:

Here are Ryan’s videos on

Let me know if I can provide any more details.

This is because the problem lies outside of the LookAt Function and is based upon where it is being called/what’s being passed in/how often. I see it’s being called from “Interaction Trace” but that itself is also a function which must be called, so we need to go up further in the chain of events. Where is “Interaction Trace” being called? Tick? If so, changing it to only be called on when asked may be the answer. It’s possible tick is restarting the logic at different points in the execution line here.

Looking a little closer I notice your “Content” array of structs is being Replicated. Is that intentional? This could be a new thread to follow for the issue, you could have the server and client fighting over what’s correct. I’m not sure about that one, though, it’s just a thought because it seemed out of place.

I appreciate your suggestions. Yes, the “Interaction Trace” is being called by EventTick. Here is the event graph of BPC_InventorySystem from which it is called.

Is there another way of constantly checking for an interactable actor other than tick? If Tick were to restart the logic at different points in the execution line, wouldn’t this affect both actors (the remote and the door)?

Ryan suggested replicating “Content” in his tutorial to ensure online capability (admittedly not something I need at this time). Setting replication to “none” does not seem to change anything.

After doing some tests with a friend I’ve finally managed to identify the issue.

There were two actors with the inventory component that performs the interaction trace on a tick event basis, leading to a redundant performance of the functions involved. The inventory function was only supposed to be part of a single actor (the player character blueprint). When experimenting with accessing inventory data I had added the inventory component to another actor in the past, not understanding the implications of this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.