Battery C++ Tutorial

HI,

im trying to get the C++ battery tutorial work.
But I can’t figure out why I’m not able to use FActorSpawnParameters or World->…
What am I doing wrong?

It tells me: FactorSpawnParameters is undefined or pointer to incomplete class type is not allowed (for World->).

#include "SpawnVolume.h"
#include "Components/BoxComponent.h"
#include "Kismet/KismetMathLibrary.h"
#include "Pickup.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 = false;
	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);

}

FVector ASpawnVolume::GetRandomPositionInVolume() {
	FVector SpawnOrigin = WhereToSpawn->Bounds.Origin;
	FVector SPawnExtent = WhereToSpawn->Bounds.BoxExtent;
	
	return UKismetMathLibrary::RandomPointInBoundingBox(SpawnOrigin, SPawnExtent);
}


void ASpawnVolume::SpawnPickup() {
	if (WhatToSpawn != NULL) {
		const UWorld* World = GetWorld();
		
		if (World) {
			FActorSpawnParameters SpawnParams; //IS UNDEFINED

		}
	}
}

Hi,

wow thanks for your answer. It helped me alot! :))

Hey, make sure to read and understand all the new changes how Unreal includes his header files now
Then, you can search for your headers in the api. After typing in FActorSpawnParametes, you can see that you need to include Runtime/Engine/Classes/Engine/World.h for example.

UWorld seems to be an exception. You can still use the functions, because Unreal will know them from the pre-computed-header file (pch). You won’t have the auto-compete in Visual Studio though.

Would be awesome to hear if you can make it work! <3