繁体   English   中英

如何修复虚幻引擎 4 中的“不允许指向不完整类类型的指针”错误

[英]How to fix "Pointer to Incomplete class type is not allowed" error in Unreal Engine 4

我正在尝试使用 Sharan Volin 的一本名为“通过使用虚幻引擎 4 创建游戏来学习 C++”的书来学习 C++。 到目前为止,我一直在关注这些例子,但我被这个错误困住了,尽管我正在逐字输入文本中的所有内容。 有什么我遗漏或不理解的吗?

我试图看看这个练习是否有任何其他指南或 Git Repos,但没有运气。 关于错误代码 E0393(我得到的错误)的其他 Stack 用户问题似乎没有帮助,因为Avatar.h文件中包含Avatar.cpp文件。

这是Avatar.cpp文件中段中的Avatar.cpp给我一个错误,特别是最后两行以PlayerInputComponent->开头

// Called to bind functionality to input
void AAvatar::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
check(PlayerInputComponent);
PlayerInputComponent->BindAxis("Forward", this, &AAvatar::MoveForward);
PlayerInputComponent->BindAxis("Strafe", this, &AAvatar::MoveRight);
}

这是Avatar.h文件中的一些代码,只有最后 4 行是我被指示输入的内容。

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

    // Called to bind functionality to input
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

    //New! These 2 new member function declarations
    //they will be used to move our player around!
    void MoveForward(float amount);
    void MoveRight(float amount);
};

最终结果应该允许我在分别按下“W”和“D”后将虚幻项目中的化身向前和向右移动。 但是,在Avatar.cpp文件中,我收到错误E0393 pointer to incomplete class type is not allowed 我也从未让项目在虚幻编辑器中启动。

只需转到头文件“Avatar.h”并键入#include“Components/InputComponent.h”

在您的 cpp 文件中,您已经向前声明了该类。 您需要在 .cpp 文件中包含实际定义的包含。 所以你需要包含 UInputComponent。

在组件的文档上: 在这里您将在页面底部看到它在引擎文件中的位置。

#include "Runtime/Engine/Classes/Components/InputComponent.h"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM