I have two classes in C++:
Class A derives from UActorComponent and is supposed to be a Base Class
Class B derives from A
In Blueprints, I want to store an Object of class B in a variable of class A. This isn’t possible (“B Object Reference is not compatible with A Object reference”)
However, I don’t have any issues storing an Object of Class B in a variable of class UActorComponent.
How can I tell class B, that A is its base class?
Edit: Here are the classes:
Class A
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "ClassA.generated.h"
UCLASS( ClassGroup=(MyClass), meta=(BlueprintSpawnableComponent) )
class GAME_API UClassA : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UClassA();
UFUNCTION()
virtual void myfunction();
protected:
// Called when the game starts
virtual void BeginPlay() override;
UFUNCTION(Server, Reliable, WithValidation)
virtual void Server_Function();
UPROPERTY()
bool bVar = false;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};
Class B
#include "CoreMinimal.h"
#include "ClassA.h"
#include "ClassB.generated.h"
UCLASS(ClassGroup = (MyClass), meta = (BlueprintSpawnableComponent))
class GAME_API UClassB : public UClassA
{
GENERATED_BODY()
public:
virtual void myfunction() override;
};