Download

Parent BP or BP Interface?

Hello everyone,
I’m creating a system for my project (a game i’d like to introduce in here sometime soon… xD) to collect items. So first i created a BP and added some general behaviour nodes like “On Component Begin/End Overlap” and such. Then added a custom event for the process of “examining” the item (pressing a button in front of it).
I used that BP as parent so i made some new BPs for some items to get and in the class i searched for that BP i want to use as parent and selected it. This way i can use those events by default without having to recreate them everytime i create a new item.
And well… long story short (now lol) i realized that i could use bp interfaces for that. But in my little knowledge about the engine i don’t really know which option should i get in terms of general usage or in memory cost, processing, etc. So that’s my question: Use a Parent BP or a BP Interface for this stuff? If i keep using this ‘parent’ system will i get any kind of error?

Thank you everyone for your time and in advance for any help provided.

Hello,
Parent blueprint and interface blueprint are two different things. Parent blueprint is a blueprint which let you create a child that you’ll use in game which will have particularities inherited from its parent and particularities of its own. An interface blueprint is a communication blueprint between two different blueprints in game.

Hello Fen and thank you for your answer! :slight_smile:
I know they are different but for the use i’m giving it, i could use an interface instead of a parent bp (afaik) and share it to all the item BPs. That’s why i want to know which one is better in terms of performance or if there is no difference.
Maybe i’m wrong and i can’t use interface for that then sorry for my mistake :stuck_out_tongue:

If you want to set variables / functions / events usable in a lot of blueprints and they all have the same, you have to use a parent blueprint and use the ability to use all of the parent blueprint.
Interface will be used only when you need to communicate in game for example, you have a detection system which scan if you have the right code on you (badge, implant or nano robot ^^) In your character you’ll set the variable and send it to interface and all blueprints linked to the function in the interface will receive it.

If i don’t mistake, you don’t have / need communication in game in your situation so you would use parent.

Edit : When your character will pick the item then you’ll “cast to” parent and check infos / or use interface if for some reason you want to use one. But for the common stuff using a parent to create all your items is better than having a bunch of different blueprints) and you will save a lot of communication / ressources eater.

Oh i see! now i understand it far way better thanks to you. I was missunderstanding the use of the interfaces.
Thank you very much for your help Fen!

Got a new question/problem and dunno if i should post it here or make a new topic but due to that this problem is related to the same system i’m making i decided to post it here:
I built a save system to store in an array the items i get. So in the graph of the parent’s item i add a “self” node to the array.
In an event begin play node i check if the “self” is stored in that array and if so then i destroy the actor. The problem is that i get one item and then when i reload the game not only that specific actor gets destroyed but all of them that have the same parent BP.
So “self” is not a way to uniquely identify an actor? or atleast not a way to identify a child of a parent BP?
What can i do to solve this?

PS. I tried to store the “self” in every child BP instead of the parent BP but the result it’s the same. It’s like if a child BP’ “self” gets the parent’ “self”…

Thank you for your time!

are you doing the begin play in the parent bp? if so the childs will also execute that begin play… you need to override the event and add a separate Begin play to every child bp

Thank you for your answer ruohki!
Well i tested both ways; in the parent BP and in the child’s but the result is the same.
Actually i want all the children to execute the begin play event but still they shouldn’t get destroyed because this only shoudl happen if “self” it’s saved on an array controlled by the game player :S

Do a branch on the array with a “Contain” command

Here are my graphs for begin play and for event destroyed (when i pick up an item i destroy it so this event gets executed to look for self in the array and if it’s not there then it’s added.)

Event Begin Play

&stc=1

Event Destroyed

&stc=1

PS. “Item Recogidos” it’s the array that should save the “self” for every item but looks like the “self” in this case its equivalent to the parent’ “self” and it’s the same one for every children.

PS2. we posted at the same time xD. And yeah that’s what i already have but the result it’s the same.

I tried adding a player character’s variable which gets the value of “self” from the item BP too but only when you “examine” it but still the same result :S I’m frustrated
I came from GameMaker (yeah such a BIG jump) and i used a similar method in there to store items but in there every object has an ID even more every instance of an object (this should be similar to every child of a parent) gets an uniquely specific ID but i couldn’t find something like this in Unreal :frowning:

So i’ve managed to fix it… sort of…
In every child BP i added a “self” node and then promoted it to a variable and added this new variable to the array instead of the “self”. And this way it worked

But thing are getting weird. In some of the testings i changed the way the items analize the array to see if they have to be destroyed.
I tried adding a sequence in the load actor (this one looks for a save game at the begin play and loas the array to the player if that so) where it gets all actors from class (here i selected the parent BP for items) and then make a ForEachLoop then in the array element i cast to the parent item BP and look for it in the array of items collected and if it returns true then it gets destroyed.
And then deactivated the check in the parent BP’s begin play event.
Tested like this and no item got destroyed…(?)
Tested with only the check in the parent BP’s begin play event and all the items got destroyed (just like the beggining)

And the weird thing comes here:
Tested with both checks actives and now it works (!?) it only destroys the specifics actors on the array and not all of them :confused:

So now for it to work i have to have 2 checks in the array to destroy the items correctly. Whenever i try to deactivate any of the checks (i repeat they do exactly the same xD) then it stops working. This is the weirdest thing i’ve seen so far while working with blueprints

PS. Sorry for triple posting just wanted to keep it bumped so anyone who already read it could read the update (aswell in case anyone has the same error as me too)