How to share variable of same blueprint classes

I open my first door, it’s locked (bool variable set to false for locked) then I go to my second door, try opening it(locked aswell), but after trying to open the Second door the First door Bool of locked becomes true from false.
The Doors are copies of the same Blueprint class.
The question is how can I change the variable of ‘locked’ from the first Door after touching the Second door, because all the variables seem to be local and not global.
So changing the lock status can only be done on the door I am interacting with

Are you asking how to create this behaviour, or is this behaviour currently happening and are you trying to fix it?

What should the doors be doing?

No im asking how to create this behaviour without casting, because sure I could cast all the doors to each other, but that would be too many doors.
I will have like tons of door in my game and only if they are opened in a specific order it’s supposed to unlock each other

Perhaps the Door class could have a variable of the same type (variable ‘nextDoor’) and when you try to open a door, it sets the locked variable on nextDoor.locked?

This way, each door would be referring you to the next when you try to open it

yes I tried that with the variable “First Door opened?”, but it only changes it inside like the first Door, so the second door “First Door opened?” variable is unchanged

Could you post pictures of the Blueprint, perhaps that will clear things up?

You could do it this way:

My Products

1 Like


Can I use the Interface Return Value maybe?

But this is casting BP_door everytime I’m interacting.
Not very performant or?

I don’t know how you interact with the doors and how you get a link to them. I just assumed that it would be some collision.
One cast costs nothing.

1 Like


So basically this is how I interact with the Doors. And the last part is where it doesn’t work.
The Variable First Door Activated only sets up the door I interact with and not the other doors.
Like for example when I touch another door which is the copy of this class, it doesn’t change the first door

I don’t see interaction here, only a reaction to it. How are you calling this function?

1 Like


It’s called from my First Person character, when he is interacting with it and checking if it has the Interface enabled

I would number the doors with the Index variable and process them in pawn actor.

I see no reason to use a blueprint interface here.