Is there some kinda global variable or something similar that's easy to do? (UE5)

I am trying to make a door open, but only when you’re looking at it and when you’re close enough. I’ve tried a few different things, but I don’t really know what I’m doing as I’m really green to unreal, and when I asked my teacher he went way to fast and I didn’t really understand anything.

That’s the code I have so far along with this


I don’t really understand the code in the second image as that’s what my teacher did.

Visual references would be a great help if you know how to do this, thank you!

The code in the second image is supposed to shoot a line trace in the direction of the camera and when it hits the door it sets the variable ODCanInteract, which allows you to open the door. You need a branch node, and when display name = “the doors name”, set ODCanInteract to True. Hook up a print string node to stuff that you don’t understand.

Hey @IzzIzzIzzIzzI! Welcome to the forums!

So what @jay001020 here said is accurate, however the display name tracking is not something most do anymore. Because depending on the actor itself, that display name can be different. Most get a letter and a number after the spawn to differentiate identical actors.

Usually, this is done through tags these days.

You can add a “Tag” to anything. Typically one would add an “Interactable” tag to the door, then off of hit actor use “Actor has Tag → Interactable” then a branch, off “TRUE” set “ODCanInteract”.

You can add a tag to something by opening the actor, selecting the root, and in the “Details” window, it’s at the very bottom by default or you can search tag, and hit the “+” to type it in :slight_smile: