You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unreal与Flask控制NAO机器人代码报错求助(VS2019)

Unreal操控NAO机器人的两处代码报错解决

报错1:头文件E0077错误

错误信息

Error (active) E0077 this declaration has no storage class or type specifier,位于InternshipUnreal项目RobotArmController.h第17行

问题代码片段

UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class INTERNSHIPUNREAL_API URobotArmControllerComponent : public UActorComponent
{
    GENERATED_BODY()

解决方法

  • 确保头文件开头包含必要的依赖头文件:
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "RobotArmControllerComponent.generated.h"
  • 补全类的完整定义,添加必要成员声明并正确闭合类:
UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class INTERNSHIPUNREAL_API URobotArmControllerComponent : public UActorComponent
{
    GENERATED_BODY()

public:
    URobotArmControllerComponent();

protected:
    virtual void BeginPlay() override;

public:
    virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
    void MoveArm(float Position);
};

该错误多由类定义语法不完整(如缺少成员声明、未闭合})或依赖头文件缺失导致。


报错2:cpp文件E0135错误

错误信息

Error (active) E0135 class "UObject" has no member "TickComponent",位于InternshipUnreal项目RobotArmController.cpp第14行

问题代码片段

void URobotArmControllerComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

    // Call the MoveArm function with the new position
    MoveArm(GetOwner()->GetActorLocation().Y);
}

解决方法

  • 确保cpp文件开头包含组件头文件:
#include "RobotArmControllerComponent.h"
  • 在组件构造函数中启用Tick功能(需先在头文件声明构造函数):
URobotArmControllerComponent::URobotArmControllerComponent()
{
    PrimaryComponentTick.bCanEverTick = true;
}
  • 检查头文件中TickComponent声明是否正确标记为override,确保继承自UActorComponent的对应方法。

该错误是编译器将Super解析为UObject而非UActorComponent导致,根源为头文件引用缺失或Tick功能未正确启用。

内容的提问来源于stack exchange,提问作者simal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 02:46:09