同上,我原本是學習藍圖的開發者,最近打算學習 C++ 但是我在設定完 VS 2022 的基礎設置(勾選 VS 安裝程式的 C++ 遊戲開發、.NET桌面開發、C++桌面開發與MSVC等需要的個別文件等)
然後創建新的 C++ 類時發現剛創建的文件一直出現報錯,網路上找了很多方法與詢問但終究沒有得到幫助,有沒有人知道怎麼辦解決
你继承UObject 当然不可能有 BeginPlay(), 你要继承AActor 之后的类才会有这些功能
我剛剛重建一個新 C++ 類再次比對一下,因為我發現舊的檔案有寫過一些東西所以開的檔案重新研究這個 Error 問題
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”
UCLASS()
class SPLINTERED_HORIZONS_API AMyActor : public AActor
{
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.cpp
```cpp
// 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();
}
// Called every frame
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
```
上圖的繼承跟現在這個 MyActor 都是繼承 AActor 以及報錯都是一樣的
感謝你的回覆,之前 B 站跟其他平台都找不到人能教我怎麼修復,會不會是 Visual Studio 2022 本身的一些問題
