Change Struct Boolean to True/False from BP Actors

Hello,
as per object i was wondering if there is any way to change the state of a Boolean inside a Struct trough a Box Collision in game.

I will explain my case in details.

I have an inventory that i made following a Udemy Course.
The inventory has its own Structs to store items data (Can be dropped, can be used, item name, desctiption etc.)

These value are being set inside a child BP of a BP Actor “Inventory Item Master”.

I saw a similiar question on this forum (here), where the answer was this:

You can use set members or make.
Inside your actor “shop” you should already have a variable type “your struct”, connect it to a “Set members in “your struct name””. Select the Set members node, on the right side tick the option you want to make visible and set it in the event graph. Connect the output to your first created variable on your actor to set the reference on it.
The diamond output instead of a circle is because you are creating a new reference.

Basic setup:

I tryed it, but it seems not working.

Following i attach detailed screenshot of my situation, i hope that someone could help me figure out how to solve this:

This is the Item Data struct:

This is the Item Master:

In the screen you can see the 2 childs.

This is one of the child in detail:

So i tryed to make the variable “Can be used” to False when not overlapping the door and to set to true when overlapping it, as it follows:

But my knowledge about these structs are very poor and i obviously didnt make the correct code.

Can someone help me please?

Thanks in advance!

This looks fine. Since you’re saying it’s not working:

  • how are you testing it?
  • why do you think changing the bool variable state did not happen?
  • how and by whom is this variable accessed later on?

Hello!

Sorry for not including these details!

So, i have the inventory menu with a drop down menu that shows up when i click on the item.
If the item has the bool “can be used” set to true, then in the dropdown menu appears also the voice “use”, if it set to false the “use” option is not available.

In my test i saw that the “use” option remains available.

I am currently recording a small video to explain the issue.

Thank you so much for your quick response!

Can you show how this dropdown menu reads the data? I’m under the impression it may be stale.

Just to ensure we’re on the same page, is this like a point & click game? We approach an object, the player’s proximity affects the way it behaves, right clicking brings up a context menu? How close am I?

Hello,

no it is a classic first person horror game.

This is the dropdown menu widget:

image

And this is his code:

This is the inventory slot:

image

And this is his code:

This is the inventory menu:

And this is his code:

This is the inventory grid code:

This is a short video of what i am trying (i hope i set the correct access to it):

(I tryed also without touching the Item Name pin, still not work)

Thank for your patience!

This is (probably?) incorrect:

You’re reading class defaults instead of the actual data from the door actor. Think of the class as of a template from which each door is instantiated. Those instances hold the actual mutable data.

That’s a lot of script to go through. I do not understand it and figure it out is a huuuge time sink. Could you briefly explain how it’s supposed to work.

Can you explain what is happening in the game?

  • we approach the door
  • we right click (what - the door?) or the UI?
  • a menu pops up - we click Use
  • if the door can be used and we have the correct key in the inv, the door opens

How is the data from the door supposed to end up in the menu? All I see is you trying to read something form the player’s inventory - surely the player does not hold the door. The door is somewhere in the world?

I am assuming this is the door actor whose data we try to access somewhere in the UI:

Correct?

Hello,

so the door is BP Actor placed in the world.
THe door holds a collision box and a gate. The input is enabled when in the collision box.
If i hit E (interact) when inside the box collision, then the door opens.

Now, in the door i set a bool and a branch to check if the player has the key. If true, the code goes on and the door opens. If not, play sound of a locked door and call a widget that says “its locked”.

The inventory has the use option in the dropdown menu. When i click on use, i can call everything on that event inside the BP_HallKeyItem (for example i can set the bool “has key” on my character to true. But i would like to be able to USE only if near the door (for example inside the door box collision), not everywhere.
I tryed to use a branch after the USE function inside the BPHallKey Item, the condition is a bool called “IsNearDoor” that sets to true when inside the door box collision. If false, do nothing. Seems to work since the bool “has key” is still set to fals, BUT the key in my inventory get destroyed anyway just like if i used it. I know the part of the destroy actor is another huuuge part of the code here, so i know that it could be really difficult figuring out how to solve this. In the meantime i asked to the course owner since he does not cover this situation in his course…

Hope you can help me,
Thanks!

I add that the inventory data ref is a reference to the structs that holds the item data (not the speific key now that i think…)

This topic has been moved from International to Programming & Scripting: Blueprint.

When posting, please review the categories to ensure your topic is posted in the most relevant space.

Thanks and happy developing! :slight_smile: