Hi guys! I’m developing a couple of related Actor Components in C++, and they both derive from a parent class.
I was just wondering if it was possible to have the child class as a UClass while the parent isn’t? Also with that being true, can I still make functions in the parent use the UFunction metadata so that they appear in the child in blueprint?
I assume you mean parent would not have UCLASS() and child would not have it. You can’t do it, reflection system only support classes that inherents UObject which contains most basic object managment code and UObject requires UCLASS(), so if you use component you need to use UCLASS(). Reflection system also does not support non-UObject classes (but C++ still normally support it, but they won’t be managed by UE4 code anymore).
But structs practically works the same as class in C++, so you can use USTRUCT instead. Problem is reflection system only support properties, also it does not support struct pointers, you can use functions in structs in C++ but without UFUNCTION reflection system does not support struct functions, but you can make static UObject functions for struct for blueprint use, same as UE4 does with FVector or FRotator which are also structs.
If you what you want is to some how hide parent class so it not spwanable or soemthing, just add “Abstruct” specifier to UCLASS(), it informes engine that this class is meant to be only base parent class for something.
Thank you for that informative answer! I’m glad you were able to understand what I was trying to do, the Abstract specifier is exactly what I was looking for!