How do I set the type for a variable to a Blueprint Interface?

I wish to have an actor hold a reference to a “Current Weapon” in a variable. That variable should hold a reference to any Blueprint that implements my Blueprint Interface “BPI_Weapon”. I see that the dropdown for variable types includes the category header “interface” and that it appears that no selections are available beneath it. When I mouse over that category header it displays a tooltip that reads “interface pointer.”.

How do a store a reference to a blueprint interface in a variable? Do I need to flag something on my interface to make it available as a variable type?

It is very simple. All what you need is just not pick (bool, int, vector…etc). you need to write the first few letters of the other bleprint, and then you will see it appears in the list with an extra “_C”. for example:

  • I made 2 blueprints, “Play” & “someStuff”

  • I wanted to make a var inside the first one, with the type of “someStuff” blueprint

  • Just open the drop down & write whatever you want .!

alt text

Thank you for your quick response, but I think that you are explaining how it works with standard Blueprints and not Blueprint Interfaces.

I have 1 Blueprint Interface (BPI_Weapon) that defines some functions, 1 Blueprint (BP_Pistol) that implements that interface, and 1 Blueprint (BP_Character) that I want to have a variable named currentWeapon of type (BPI_Weapon) with so that I can create more implementations of the same interface and use the same reference to swap between them.

Any reason you are using an interface rather than a base ‘weapon’ Blueprint with the specific weapons as child BPs of that? The advantage to that is you can put functionality in that base BP.

That is how I’m currently implementing this functionality, but isn’t that counter to the concept of an interface?

I intended to create a logical boundary between the caller of the interface and the implementation of the interface. For example, my “trap” weapon’s do not work the same as my “gun” weapon’s, but both of them should be executed from the same caller the same way. Are you suggesting that I should create an abstract “Weapon” blueprint, a “Weapon_Trap” blueprint, a “Weapon_Gun” blueprint, and then have all three implement my BPI_Weapon blueprint interface so that I can guarantee that all of them follow the same pattern and then have the “Current Weapon” hold a reference to the abstract “Weapon” blueprint?

Perhaps I’m not understanding this correctly, but it seems very simple implementation if blueprint interfaces can be referenced as a variable type.

Hi Jeremy,

Not sure if this was still bothering you, but I’m in the same situation atm. It seems epic is still getting around to implementing it (4.3 got a step closer to having an interface variable type). In the meantime I’m just storing the variable as type ‘object’ and casting to the interface when needed. A little ugly, but it’s a viable work around in the meantime.

When full support for it comes in we’ll just have to go back through and change it :stuck_out_tongue: