Blueprint Interface doesn't work

Trying to do simple bp interface and faced with troubles.
I have player BP that have such simple controls to call the event
UEi1
This BP doesn’t have the interface in class settings


Here is the interface

Here is my gun BP that must take commands from player BP
UEi4
I added my interface to the class settings

Calling the event does nothing, can’t change the bool variable on the fly and I have no idea what goes wrong, I literally watched several guides and don’t see where I made a mistake
I will be glad to any advice

The whole point of a BPI, is that you make the call from one actor to another.

I can see from your ‘self’ reference, that the calling actor, is calling the interface on itself.

You need a reference to the actor with the other code you have shown there…

Ok, this means I need to have a cast to the gun BP but the reason to use bp interface was to avoid using hard coded casts

No casting, just use a reference to the gun. ( you have the right idea ).

I have 3 guns and plan to add more, so is this mean that I need to copy/paste this message for all of them?

Ok, this is working but how to make it simpler?

No.

Each gun should be derived from a common gun BP. That BP will have the trigger response event.

Then you can call the event using an interface.

The shooting allowed bool should only be set on each gun, one at a time, no?

I want to turn it on on all my guns. I didn’t understand how to get such ref for all guns

There is no ref for all guns. Are these guns components ( in the player ), or actors?

I attached them in this way

Ok, so they’re all the same type.

You can do GetAllActorsOfClass, and set them.

Thanks this works fine

1 Like