Hi, I’m following along with this tutorial: Unreal Engine C++ Tutorial - Episode 2: Pickups - YouTube but I’m getting an error “pointer to incomplete class” when trying to assign a static mesh to a root object via the SetupAttachment function, I’ve included #include "Components/ShapeComponent.h"
, #include "Components/SceneComponent.h"
, and #include "Components/StaticMeshComponent.h"
already and it seems to compile fine but the error still shows.
Pickup.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/BoxComponent.h"
#include "Components/ShapeComponent.h"
#include "Components/SceneComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Pickup.generated.h"
UCLASS()
class YT_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)
USceneComponent* PickupRoot;
// The static mesh for the pickup
UPROPERTY(EditAnywhere)
UStaticMeshComponent* PickupMesh;
UPROPERTY(EditAnywhere)
UShapeComponent* PickupBox;
UFUNCTION()
void OnPlayerEnterPickupBox(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
};
Pickup.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#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;
PickupRoot = CreateDefaultSubobject<USceneComponent>(TEXT("PickupRoot"));
RootComponent = PickupRoot;
PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MyMesh"));
PickupMesh->SetupAttachment(PickupRoot);
}
// Called when the game starts or when spawned
void APickup::BeginPlay() {
Super::BeginPlay();
}
// Called every frame
void APickup::Tick(float DeltaTime) {
Super::Tick(DeltaTime);
}
void APickup::OnPlayerEnterPickupBox(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult) {
Destroy();
}
Also sometimes when I make a change to a source file I get a long spew of errors saying everything is undefined, anyone have any idea whats up with that? I’m using VS Community 2017 if that helps.