在生成Actor(虚幻引擎4)时出现错误

Plethora of errors upon generating an Actor (Unreal Engine 4)

本文关键字:错误 引擎 Actor      更新时间:2023-10-16

前几天刚开始进入虚幻引擎,但当我试图从编辑器中创建一个新的actor时,我在Visual Studio中立即出现了错误。

我根本没有更改任何代码,但我收到了87个错误。

这是一些错误的图片。

我已经在下面发布了我的两个演员档案,并可以在任何有错误下划线的行旁边发表评论。这是我对代码所做的唯一更改。

这是我的"MyActor.h"文件。

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"  //Red underline under '#include'
UCLASS()  //Green underline under 'UCLASS'
class BIGFEET_API AMyActor : public AActor
{
GENERATED_BODY()  //Red underline under 'GENERATED_BODY'
public: 
// Sets default values for this actor's properties
AMyActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public: 
// Called every frame
virtual void Tick(float DeltaTime) override;

};

这是我的"MyActor.ccp"文件。

// Fill out your copyright notice in the Description page of Project Settings.
#include "MyActor.h"

// Sets default values
AMyActor::AMyActor()
{
// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
Super::BeginPlay();  //Red underline under 'BeginPlay'
}
// Called every frame
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);  //Red underline under 'Tick'
}

我想这是发动机的某种设置问题,在做了一些研究后,我一直不知道该怎么办。如果有任何帮助,我将不胜感激!

大多数错误在其他帖子中都有具体的答案,但要关注"过多"问题:

  1. 不要惊慌
  2. 选择一种类型的错误首先进行排序。当你遇到很多错误时,他们往往会成群结队地搜寻
  3. 对错误进行优先级排序。例如,如果它以"找不到文件"开头,您可能会得到许多相关的错误,比如blah是未定义的。修复include目录或忘记的include等可能会消除其他几个错误
  4. 有些错误是由打字错误或缺少分号引起的。仔细阅读错误并查看正在调用的行。你可能发现了一些东西,或者意识到前一行缺少分号或大括号,或者其他会导致后续一连串问题的东西
  5. 如果你收到了intelligense或警告,也要阅读。这可能会让你对根本问题有另一种看法
  6. 不要惊慌。我已经说过了,但一次挑一个,但还是优先考虑
  7. 定期编译小的更改,而不是花几个小时写代码,然后一次解决所有问题。这不好玩