Hello community! I’ve been blueprinting since UE4 released and I finally started learning C++. I can say it’s going very well, but I need some help fully understanding something.
I understand how Parent and child blueprints work-- Right click and create child blueprint. Now, what I want to do is basically the same thing except in C++, but am failing to do it correctly or just ******** something up.
So, I have a C++ class based on Character and then I created a Blueprint based on that. It contains both blueprint and C++ logic and I made a child blueprint based off of that. How would I go about implementing C++ logic for that Child blueprint?
Or… what are the correct steps to achieving what I’d like to do, which is writing c++ logic in both the parent and the child separately with both as blueprints.
Think of Blueprints as wrappers for your C++ file. When you create a Blueprint based off of your C++ file, all functions and variables are accessible within the Blueprint… IF you make the property “BlueprintCallable”. Then, within the Blueprint, you can see the variables that you create, and call the functions that you allow to be called.
You can’t have what you are asking for. You can have a base C++ class, then make a BP Child of it. Then you can make a C++ child of the C++ Base class and then make a BP Child of the Child C++ class, but it won’t have the first BP’s stuff in it.
In straight C++ you would be allowed to through multiple inheritance, but can/will cause bugs known as the Diamond problem. You can’t have multiple inheritance in Blueprints or C++ in UE4 so it doesn’t matter.
Depending on what you need making a more of a component system (not necessarily the built in component system depending on what you are doing, but possibly) instead of straight inheritance may work better for you, that way your object has a collection of stuff in it, but they aren’t directly sub classing it. It could be a bunch of different C++/BP class that have a common base type and your object can manage them.
Or, making an Interface may solve your problem. It really depends on what you are trying to accomplish.
Thank you, this was the information I was looking for. A component system is actually the way I am approaching it now and it fulfills my needs, but I was thinking that there may be a way to do what I wanted. Now that I know I can’t, I’ll work with what’s possible.