What is a parent and child?
Very strange choice of terms. This comes up a lot in the engine, but I've no idea what they mean.
asked Aug 01 '15 at 04:08 AM in Using UE4
Well, it's really simple. Its a concept you find everywhere in programming. For example a parent class would be a mammal, and multiple child classes would be a human, a dog and a cat. Because they are all basically the same, just with some differences. But they can all eat, die, look around, grow, get older, etc. Different to for example a street lantern. So a street lantern would not be a child of mammal. At least I don't know any street lantern which would fit in there ;) With having a parent and multiple childs you can set up functionality and share it in multiple childs, which can extend to it, but they all have at least all the basic functionality.
answered Aug 01 '15 at 05:17 AM
Much like John said above. A parent sets the basic parameters for each of it's children. Each child "inherits" the same variables, functions, macro's, etc but can override what the parent has set as default behavior as well as create it's own unique variables, functions, macros, etc..
One of the great things about using the parent/child relationship is it makes it easier when casting and searching for particular instances. For example, I am building an RTS similar to Tropico. I have a Building Master BP then I have a child "Residential", "Commercial", and "Industrial" BP that inherits everything from Parent because they all have the same basic needs. With the children, I add specific functionality to each one because Residential has different needs than commercial, industrial, etc.. Then I create my actual building BP as children of the Residential, Commercial, and Industrial BP (which would then make the new ones "grandchildren" of the original Building Master.)
Now, when I go to select the building for, lets say, getting a widget to pop up, I check that the item being clicked and/or hovered over is a descendant of the Building Master BP. If it is, then I display the Building Widget. This makes it much easier to find rather than checking every single building BP individually - if it's a descendant of the Building Master BP then it must be a building. Using parent/child BP has many advantages and is well worth the practice in using them. As a side note, in the next couple of weeks I will be doing a tutorial series on my channel showing people how I am building my RTS game. In my setup, I have many instances of parent/child relationships as well as I use many proxy and manager style blueprints to help organize and easily use the system together. Great for streamlining everything. If interested in checking that out when I start the series then let me know and I will give you my channel name.
Hope my explanation helps!
To add, Child and Parent in UE4 is also to define relationship between components in actor, child component follows parent component, parent component can also control child components and vice versa depending how they are coded.
Unlike class relationship which kind of defined it self in community, this component relationship terms are officially named that way in engine, so watch out to not get confused. Sometimes you can hear child class being called "Subclass" of parent class as engine officially names them this way in one of the C++ types (TSubclassOf which is UClass* just in editor menus it limits selection to specific class relation)
answered Aug 01 '15 at 10:02 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here