Is there a way to get a reference for a model from separate blueprint ?

Hi

Is there a way to get the same reference for this object but from another blueprint in the project ?

currently I have inside the level a model or object selected when I open level blueprint and right click I can see the option to get a reference to this object

Thanks

1 Like

Hey @william5642!

You sure can, there are many ways to go about doing that.

One way would be setting it as a variable using a public variable.

Another would be setting it as a variable using “Get all Actors of class” and filtering it down.

Try reading through this page and see if any of these seem like a way you’d like to do it!

1 Like

Thanks for providing more information I have this blueprint the fire a shell after pressing M key then I want to play a sequence what is the node to do that and how I set the target parameter ?

I see from documentation that I can cast another blueprint but if I placed a 3D model in the level without using blueprint then I can not cast for this object ?

I also want to ask everyone to show me the most convenient way to do it.

Mind-Brain give me this url it has description of different methods for actor communications

1 Like

Casting is less of a communication and more of a filter/mold. A 3D model that is in the level can be found, sure! But not through casting. For a simple Static Mesh you’ll want to stick to the level blueprint, but the level blueprint could get the mesh and the player both and have them interact by casting “Get Player Pawn” and casting it to your “Player_bp”, then “As Player BP” do your event or function on the Player!

So what casting is:

Think of it like you’re making a sword, a child of metal. You have metal as an object. You cast the metal as a sword and now the object can use “As Sword” to slash, which it could not do as just metal.

Casting is for making something you get be a more specific version of itself. And if it can’t cast to that thing, it does not continue the code, it follows the “Failed Cast” line.

So you could “Get all actors of class: Metal_parent” and get all of your metal things as long as they have “Metal” as their parent. Then you could “Cast to Sword” and get a sword, but if there are more than one it would not be specific, so then you might do something like a distance check to find the closest one.

For getting a reference for a model
This is assuming the player needs it

On the referrer, make a Static mesh variable, let’s call it “SpecialStaticMeshRef”
Click on that static mesh variable and in the details window enable “Public”.
Now, on the level Blueprint, get a reference to the mesh.
Right click in the open area and use “Get Player Character”, drag off of that and use "Cast to Player_BP (or whatever you named it), then AS PLAYER BP, SET SpecialStaticMesh.
Finally, pass in the static mesh reference.

You can do this as part of any event, like an overlap in the level or beginplay (after a short delay). :slight_smile:
Hope that helps! Let me know how it goes!

1 Like

Thanks. I created now a variable ref and set it to the object in the main level then I can use this ref variable to control the object

1 Like