I have created a new empty C++ project and then added an AActor class.
On its constructor I have tried to create a UBoxComponent but I get this error:
error C2065: ‘UBoxComponent’: undeclared identifier
This is the header:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "SpawnVolume.generated.h"
UCLASS()
class PLANETARIUMVR_API ASpawnVolume : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASpawnVolume();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
And the class:
// Fill out your copyright notice in the Description page of Project Settings.
#include "SpawnVolume.h"
// Sets default values
ASpawnVolume::ASpawnVolume()
{
// 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;
UBoxComponent* WhereToSpawn = CreateDefaultSubobject<UBoxComponent>(TEXT("WhereToSpawn"));
RootComponent = WhereToSpawn;
}
// Called when the game starts or when spawned
void ASpawnVolume::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ASpawnVolume::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
I’m very confused because I have another project created with a previous version of Unreal Engine, I have migrated to Unreal 4.16 and I don’t have to include anything to use UBoxComponent
.
Do I have to include anything? I think so, but it is very confusing.