How do I get a variable from another Blueprint?

So I’m making a FNaF game (yeah yeah, cringe, I know) and I’m trying to make it so that when the enemy is outside the door, it will check if the door is closed, if its closed it will go inside but if its not then he will walk away. The problem is, I need to access the “Door Open” variable (which is inside the door’s script) from the enemy’s script. I’ve tried every tutorial but I can’t find any answers!

(first image is the door’s script)
(second image is enemy’s script)

So you put a variable of the type of your door BP in your player. Click the eye icon next to the variable name, this makes it visible in the viewport.

You can see this variable in the viewport and there will be a little pull down list, in that list will be your door, assuming you have that in the level.

In your character blueprint you can then just pull a pin from the door variable and see all the stuff inside the door blueprint, including the ‘open’ variable.

For a generic solution (if there’s going to be more than one door), your could use collision detection to find any door actors in the vicinity of an enemy actor, and then check if they are open or not (the “IsOpen” variable of the door actor will have to be public).

One way to find door actors in the vicinity is to use this node (pass the enemy location as sphere position)

Another way: Good way to get all actors of given type in radius around main character? - C++ Programming - Unreal Engine Forums

i tried following your steps but i just dont understand
i put a variable of the type of my door BP in the player
i clicked the eye
but in the viewport theres no pull down list of any kind

You can see the variable on your player in the level?

And you have your door in the level?

If you look at the variable, there’s a 1 item pull down for your door. Or, you can use the eye dropper tool ( next to the variable ) to point at your door :slight_smile:

Like this:

309872-dropper.jpg

except it will referencing your door.

This also explains it:

1 Like

If you click your player in the main viewport, you can see the variable. That’s where you connect it to the door… :slight_smile:

1 Like