编译C 电池收集器教程的错误
Compile errors for C++ Battery Collector tutorial
对不起,非常菜鸟问题,我一直在通过Unreal的C 电池收集器教程进行工作,并且我在教程中对代码有一些编译。
我已经在Visual Studio中进行了关注,在标题文件中创建访问者方法时,我使用Intelli Sense生成了Corossonding类。
Pickup.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"
UCLASS()
class BATTERYCOLLECTOR_API APickup : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
APickup();
// Called every frame
virtual void Tick(float DeltaTime) override;
// Return the mesh for the pickup
FORCEINLINE class UStaticMeshComponent* GetMesh() const { return PickupMesh; }
// Return whether or not the pickup is active
UFUNCTION(BlueprintPure, Category = "Pickup"); // <--- error in this line
bool IsActive();
// Allows other classes to safely change whether or not the pickup is active
UFUNCTION(BlueprintCallable, Category = "Pickup");
void setActive(bool NewPickupState);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
//True when the pickup can be used, and false when pickup is deactivated
bool bIsActive;
private:
//Static mesh to represent the pickup in the level
UPROPERTY(visibleAnywhere, BlueprintReadOnly, Category = "Pickup", meta = (AllowPrivateAccess = "true"))
class UStaticMeshComponent* PickupMesh;
};
Pickup.cpp
#include "Pickup.h"
// Sets default values
APickup::APickup()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
// All pickups start active
bIsActive = true;
// Create the static mesh component
PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PickupMesh"));
}
// Called when the game starts or when spawned
void APickup::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APickup::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Visual studio created this definition
//APickup::UFUNCTION(BlueprintPure, Category)
//{
//What is should go in here?
//}
// Returns active state
bool APickup::IsActive()
{
return bIsActive;
}
// Changes active state
void APickup::setActive(bool NewPickupState)
{
bIsActive = NewPickupState;
}
在.cpp文件中添加注释Visual studio created this definition
的行上,这是Visual Studio Code添加的定义,但我不确定应该使用的是什么,并且没有此功能就无法编译。(此定义不在教程中,但VS希望我添加它。(
据我所知,我已经定义了这两个ufunctions的方法
D:/Unreal Projects/BatteryCollector/Source/BatteryCollector/Pickup.h(25) : Error: Function return type: Missing variable type
任何人都可以看到我在做错什么或缺少什么?
来自虚幻文档:
UFUNCTION([specifier, specifier, ...], [meta(key=value, key=value, ...)])
ReturnType FunctionName([Parameter, Parameter, ...])
该声明中没有;
,很可能是问题。
请注意,在编辑问题的过程中,您还将;
添加到其他声明中,但您应该删除两者。
ps:我将其作为答案,希望将半垃圾评论变成有用的东西。我不知道虚幻,也许这个答案是错误的,然后让我知道。
相关文章:
- 虚幻文档中教程项目中的错误
- 编译C 电池收集器教程的错误
- TMB教程中的此编译错误是什么?
- 当我使用的教程完全没有错误时,为什么我的代码错误
- 虚幻:按照教程"Unknown type name UTextRenderComponent"编译错误
- LLVM 教程 3.6 尝试编译第 8 章输出时的链接器错误
- Arcsynthesis OpenGL 3.3 教程的问题 - MAKE 错误
- C 中的 Malloc 和结构给了我错误(按照教程)
- C++ Metro 应用程序教程的编译错误 - 任务继续
- 叮当教程 "missing file"上的段错误
- Ogre3D尝试编译教程框架并不断收到错误.代码::块
- C++分配运算符教程中是否有拼写错误
- C++cstdlib rand教程错误
- "O_RDONLY"、"F_SETFL"'O_NONBLOCK'遵循 OpenGL 教程时未声明的错误
- 使用proto教程时链接错误
- 构建MITK教程错误
- CppCMS教程:静态链接模板错误(控制器问题)
- CppCMS 教程:静态链接模板错误:"fatal error: content.h: No such file or directory"
- Apache Thrift教程中的c++链接器错误-未定义的符号
- OpenGL教程错误