私はC++を使い慣れていなくても、Unreal Engine 4にはまだまだ新しくなっています。ビデオは、幾分古くなっているように見え、6ヶ月です。ある行でpointer to incomplete class type is not allowed
と書かれたthis->SampleMesh->AttachtoComponent(this->RootComponent);
という行に誤りがあります。私はその周りの道を探しましたが、これまで運がなかった。これを行うための更新された方法、または最新のチュートリアルを見つける場所さえ知っていれば、私は感謝します。ありがとう。unreal engine 4.18.0、Vs2017、不完全なクラス型へのエラーポインタは使用できません
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 = true;
SampleMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SampleMesh"));
this->SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComponent"));
this->RootComponent = SceneComponent;
this->SampleMesh->AttachtoComponent(this->RootComponent);
//this->SampleMesh->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
//this->SampleMesh->AttachtoComponent(this->RootComponent, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
//this->SampleMesh->AttachtoComponent(this->SceneComponent);
this->RotationRate = FRotator(0.0f, 180.0f, 0.0f);
this->Speed = 1.0f;
}
// Called when the game starts or when spawned
void APickup::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APickup::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
this->AddActorLocalRotation(this->RotationRate * DeltaTime * Speed);
}
Pickup.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"
UCLASS()
class LEARNAGAIN_API APickup : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
APickup();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(EditAnywhere, BluePrintReadWrite, Category = Pickup)
UStaticMeshComponent* SampleMesh;
UPROPERTY(EditAnywhere, BluePrintReadWrite, Category = Pickup)
FRotator RotationRate;
UPROPERTY(EditAnywhere, BluePrintReadWrite, Category = Pickup)
USceneComponent* SceneComponent;
UPROPERTY(EditAnywhere, BluePrintReadWrite, Category = Pickup)
float Speed;
};