How to make a Variable in a Blueprint Accessible in other Blueprint

I’m trying to make a variable accessible in another blueprint. I have a actor that spawns from the level blueprint and I want to be access that actor in another actor blueprint. I have the eye active on the variable but I can’t find a way to access it in the other blueprint.

Essentially, the problem I’m running into is that I want to have an actor in my environment and I want to be able to interact with it within the blueprint system using player controller pawns. Currently, I can’t find a way to reference it. The question I asked was about accessing it as a player if it’s spawned from the level. I wanted to reference it but could not figure out a way how. I tried making it a variable by setting the spawned object as the object in the variable but I could not access that variable in my player blueprint. Currently, I’m spawning it from the player but since there’s multiple players, each player has their own object that they can modify so there could be multiple instances of the same object in the level during runtime. I hope this problem was explained effectively enough for someone to be able to help me.

Looks like it might be something Involving First-Post moderation. (Anti-Spam Measure)

For your question: Be sure to give Blueprint Communications | Live Training | Unreal Engine - YouTube a watch!

I was just wondering where comments go because I left a comment earlier but I guess it didn’t go through

I’m watching it right now, thank you for the help.


When you want to interact with an actor you can use differents ways to achieve this (Raycast,Box overlapping)

Here a video that could help you to start:

Think to put the question as solved if you got an answer with

I’m trying to get it to activate when a button is pressed. I’m using input events to activate it.

Look at the tutorial i post a link to go on.

This answer to your question;

You can add id to determine who can interact with what.

I ended up watching it again and figuring out how to use casting. Unfortunately, what I was attempting to do yielded the same results as the way I was doing it originally so I just removed it. If you know, can you explain to me how multiple characters can control one object at a time. I tried setting the functions to send to server and then the server would modify stuff but it just ends up with there being two instances of what is being done. I’m trying to spawn/despawn an object but I’ve also tried spawn on level and change visibility and they both make two instances for each of the two players.

It is an actor in the persistent level. I tried referencing it in with the character but it didn’t work and I couldn’t reference it in anything other than the level script but I also can’t reference the level script with the player so I resorted to spawning but that causes an issue of there being multiple objects. Is there any other way to reference an actor/static mesh with a player blueprint without looking at it or spawning it.

It depends on the relationship between the items. Is it a specific unique item in the level? Is it listed in the AI Perception, or Box Trigger Volume? Are you standing close to it, and looking at it?

A common way for this last option, is to cast a single line trace, from the camera (so you can use your crosshairs to be accurate), and then use the Hit Actor output, to get the reference to item you need. From there, you can change any variables you want (within the actor).

Fortunately, Unreal have the documentation to do exactly this here, nice and quickly. (Using a Single Line Trace (Raycast) by Channel | Unreal Engine Documentation)

The only thing I would change is use a keypress event, rather than EventTick. They just use Event Tick to better demonstrate the result of the line trace.

I can spawn the actor but if I do it from the player. Each player is able to spawn their own version when I just want one shared actor. If I spawn it from the level or basically anything else, I can’t access it. I’m currently trying to cast to it from the player but I don’t know what object I should use in the cast. I tried get component by class already and that didn’t work. I’ve gotten spawning/despawning to work but I can’t ensure that all players will control one spawn so I’ve turned my efforts towards one actor in the level and then the players being able to set the visibility. I’ve looked at tutorials and can’t find what my object needs to be in order to complete the cast.

thanks, I’m trying it out right now

Try spawning the Actor from inside the Player BP, not forgetting to put it in the right place in the level (for example, you could use Teleport). Store it as a variable, and you’re sorted. :slight_smile:

Sorry, I’ve just seen that you tried this. Can you show your Player BP, as OnBeginPlay > Spawn Actor should have solved your problems. You could even put a Do Once node between them to make sure that you don’t get multiple spawns.

  1. Spawn the item in the level blueprint.

  2. Loop through all the players in the level. (Get Actors of Class, or Get Player Character, by index).

  3. In the loop, store the item in each of the players variables. (Give each player a variable of the specific BP type).

What i do understand is you got some amount of players.

Each of them can interact with an object let s say it s a box.

First you need to determine which of them can interact with wich box.

To do that you need to put an id in your box actor them the player can have the same id so by using node like getallactorofclass and loop to get the one who got the right id and to finish to your interaction code.

Of course action is execute to the server.

in this way that should work.