C++ 如何获得c++;当我只能从非UObject继承时,继承在actors中工作?

C++ 如何获得c++;当我只能从非UObject继承时,继承在actors中工作?,c++,unreal-engine4,unreal-blueprint,C++,Unreal Engine4,Unreal Blueprint,我目前正试图像在任何其他项目中一样实现继承,但我不断收到一个错误,告诉我只能从非UObject或UIInterface派生接口继承。我正在尝试创建一个继承AActor的MasterEntity类,然后我将拥有子类PlayerCharacter和NonPlayerCharacter,它们共享某些变量,如health,但我无法让这个看似简单的任务正常工作 我目前的档案如下 主实体.h: // Fill out your copyright notice in the Description page

我目前正试图像在任何其他项目中一样实现继承,但我不断收到一个错误,告诉我只能从非UObject或UIInterface派生接口继承。我正在尝试创建一个继承AActor的MasterEntity类,然后我将拥有子类PlayerCharacter和NonPlayerCharacter,它们共享某些变量,如health,但我无法让这个看似简单的任务正常工作

我目前的档案如下 主实体.h:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MasterEntity.generated.h"

UCLASS()
class THIRDPERSONGAME_API AMasterEntity : public AActor
{
    GENERATED_BODY()
    
public: 
    // Sets default values for this actor's properties
    AMasterEntity();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    int32 maxHealth;

};
PlayerCharacter.h

// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Components/BoxComponent.h"
#include "InteractionInterface.h"
#include "MasterEntity.h"
#include "PlayerCharacter.generated.h"

UCLASS(config=Game)
class APlayerCharacter : public ACharacter, public AMasterEntity
{
    GENERATED_BODY()


public:
    APlayerCharacter();

    
protected:

    /** Called for forwards/backward input */
    void MoveForward(float Value);

    /** Called for side to side input */
    void MoveRight(float Value);

    /** 
     * Called via input to turn at a given rate. 
     * @param Rate  This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
     */
    void TurnAtRate(float Rate);

    /**
     * Called via input to turn look up/down at a given rate. 
     * @param Rate  This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
     */
    void LookUpAtRate(float Rate);

protected:
    // APawn interface
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
    // End of APawn interface

    virtual void BeginPlay() override;

    void OnInteract();

public:
    virtual void Tick(float DeltaSeconds) override;

private:
    UPROPERTY(EditAnywhere)
    UBoxComponent* InteractionBox;

    IInteractionInterface* Interface = nullptr;
};



我错过了什么可以让我这么做?我相信我可以用组件来代替,但对于我正在尝试做的事情来说,这看起来真的很混乱。我尝试让MaSTIncItC类类只是一个规则的C++类,继承它,这并没有给我任何编译错误,但是我不能从蓝图编辑器中看到任何值(如Max Healthor变量)。“我错过了什么可以让我这么做?我相信我可以使用组件来代替,但这对于我正在尝试的工作来说似乎真的很混乱。“你已经实现了oo菱形继承。如果你想要一种通用的方式来分配运行状况,那么组件肯定是最好的选择。多重继承普遍是不好的(不包括纯接口)。听起来不错,我会的。谢谢。@George所说的+1。此外,如果你是从源代码构建引擎,你也可以直接修改AActor。