Trying to understand the relationship between C++ and BP

Hi!

im a bit confused about the way about sharing properties between C++ and BP… the image is selfexplanatory for my question…

Blueprint inheritance works just like C++ inheritance, in that you will have the member variables of your parents, but not of some random other class. If you want a class to have a property Width, then that class, or one of its superclasses, must declare a property Width.

If you want to configure a few independent things together, make them components, and add them to the same actor, you will then be able to configure values for the different components when editing that actor.

1 Like

You can inherit AMyCharacter.h from ANPCAIvin.h, i.e.
class %YOURPROJECT_API AMyCharacter: public ACharacter, public ANPCAIvin
then your ANPCAIvin properties should be exposed to your BP too

1 Like

Depends on what do you mean by “Expose”, if you want to see it in Default Value Editor, you must have the property Width as a class field in c++ (inheriting from the class with the field works as well) and create BP based on that class. If you just want to use the variable you could keep a reference to the object having that Width property and then use it from the blueprints as well

1 Like

Did you try it?

UObject reflection and unreal header tool does not work with diamond multiple inheritance, which happens when ANPCAlvin and ACharacter both derive from AActor.

Your advice does not work.

2 Likes

I didn’t try it. That’s why I wrote “Should”. But okay, I stand corrected. Thank you for clearing that out.

1 Like

thanks all for answering, pretty clear everything about this now…