Download

Blueprint communicate

Hi! I have a actor blueprint in the scene and I want to use cast to that actor in other blueprint, Get character, controller, owner for object reference doesn’t work. What is the object reference for that actor?

You will need to get the Reference by yourself. Either by an Overlap Event with Collision, a Line Trace that you could make when pressing a button or (but only because it is already in your Level) you could add
it a direct Reference to your LevelBlueprint (select the Actor, right click in LevelBlueprint and add Reference). You can then make a Reference Chain from your LevelBleuprint down to the Blueprint you need
the reference in.
If you spawn an Actor Runtime, you can directly save it’s reference at the point where you are spawning it.

I added a actor variable in Level blueprint then reference that actor blueprint = actor variable. after then still dunno how to work.
Can any professional create a special tutorial about object reference Please? Because I believe many new user include me has a big problem understanding this topic. And I want to keep asking the same topic question again and again. Thank you!!!

So what blueprint are you trying to communicate from? You may be able to do it all from the level blueprint. If not, letting us know what kind of logic you want will help.

If you could, give a description of what you want to do and share some screenshots if possible. :slight_smile:

This work if all actors are in the same level:

First, create a variable for that actor you want to cast in the blueprint you need to cast it. (For example, if you created a chair actor blueprint called Chair_BP and you want your Player_BP to be able to sit in that chair, create a variable called “ChairVar” for example inside the Player blueprint and make sure to set its class to Chair_BP .)

Second, on Event Begin Play inside Player_BP, use the node Get All Actors of Class, make sure to choose Chair_BP in ActorClass, then add a Loop node and set the ChairVar from Array Element.

From now on you can use that variable every time you want.

Now the easy way:

Alternatively, you may just make the ChairVar editable and choose the corresponding actor directly in editor without the need to use Get All Actors of Class or anything, but it may disable itself from time to time so be sure to check it. (If the variable is a generic actor class you may choose any actor in the level, but you may need to cast from it later. For specific cases it is better to just make a specific variable of that actor class and then select it in the editor using the details panel.)

In a more complicated fashion, eventually you may also use Get All Actors of Class to create an array of elements (for example if your level has a lot of chairs) and then some kind of trace cast to find what chair is closer to you (you don’t want to sit on every chair at the same time, do you?), or what car is in front of you to be able to get inside, or how many enemies and in the explosion radius of a grenade to inflict damage to just those enemies, etc.

What I’m trying to do is Mycharacter pickup an actor and drop in a room. the codes might looks like team flag I guess. And I tried few different ways to do it. But most of them need to have good knowledge on object reference.
for instance.
(in actor bp) Event overlap - attach actor to actor, because there are different actors so I put nodes in actor bp. So when I need to drop the actor, I need to Cast to that actor for detach, or destroy it and spawn a new one in the room. in this case. I need to cast to a volume actor in the room. The most difficult part for me is there are difference items to pickup so cannot just call spawn actor without using cast to.
Now I’m trying to use Structure Blueprint, but seems like another complicate topic.:stuck_out_tongue:

A structure is like a data package, instead of passing a bunch of information to another blueprint with a bunch of parameters, you could have all of them in a structure and simply pass that one. Transforms, rotations, line traces, scales, and more are examples of structures you use without even knowing it. :slight_smile: If you right click on a rotation pin input for example, it will give you the option to split it into the basic data it is made of.

It seems like you are getting around on blueprints though. :slight_smile: If you want to have a bunch of pickups in your level, try creating a pickup base blueprint class and include any variables or custom events that you want ALL pickups to have. On your custom events that you want ALL of your pickups to have, don’t actually have it do anything unless you want ALL pickups to do it, if you just leave it sit there, child blueprints will inherit it. This way, when you do a cast, you won’t have to do a cast for each different pickup. Look up more on child blueprints.

Also, with your volume actor, try having it cast to something that entered it and not have something cast to something that it entered.

If you provide a screenshot or two I might be able to narrow down exactly what you are trying to do.