【发布时间】:2019-05-16 03:43:41
【问题描述】:
我正在尝试使用 Sharan Volin 撰写的名为“通过使用虚幻引擎 4 创建游戏来学习 C++”的书来学习 C++。到目前为止,我一直在关注这些示例,但我被这个错误困住了,尽管我正在逐字输入文本中的所有内容。有什么我遗漏或不理解的地方吗?
我尝试查看是否有任何其他指南或 Git Repos 进行此练习,但没有运气。其他有关错误代码 E0393(我得到的错误)的 Stack 用户问题似乎没有帮助,因为我在 Avatar.cpp 文件中包含了 Avatar.h 文件。
这是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。我也从来没有让项目在虚幻编辑器中启动。
【问题讨论】:
-
我确实在谷歌上搜索了
PlayerInputComponent,发现顶部搜索结果是另一个网站上的相同问题。你需要知道的一切is here。简短回答:#include "Components/InputComponent.h" -
您提供的信息非常模糊和不完整。请提供更多信息。或者尝试其他 cmets 提供的解决方案。
-
你能分享一下
UInputComponent的定义吗?好像这个类还没有定义。 -
通过使用 Unreal Engine 4 创建游戏来学习 C++ -- 老实说,我真的不建议以这种方式学习 C++。 API 假设您已经了解您正在使用的计算机语言,并且您只是了解一个框架以及使框架运行所涉及的功能/类型。
标签: c++ pointers unreal-engine4