BatteryCollector Issue

Hello! I’ve been following the BatteryCollector series from UE’S Website under the Learn tab and i’ve encountered many issues.One of them is the following:

On part 6 of the series at the end of the video, she Compiles the game from within the code using VS’s build function.However my build fails outputting this error:

EXEC : error : UnrealHeaderTool failed for target ‘BatteryCollectorEditor’ (platform: Win64, module info: C:\Users\stelios papamichail\Documents\Unreal Projects\BatteryCollector\Intermediate\Build\Win64\BatteryCollectorEditor\Development\BatteryCollectorEditor.uhtmanifest, exit code: OtherCompilationError (5)).

Any ideas?(If you need to see my code,let me know and i will edit the question)Thanks in advance.

Because of the new IWYU, make sure you include everything you use. For example:

#include "Classes/Components/BoxComponent.h"

#include "Classes/Components/StaticMeshComponent.h"

This was suggested by TB, some guy commenting under the video :stuck_out_tongue_winking_eye:
Let me know if it helped! <3

UE4’s stack trace’s can be kind of cryptic especially when it comes errors in the Header files as you’ve seen - “Other Compilation Error(5)”

I’d recommend checking the “Output” tab of visual studio for more information on the error. If you could do that and upload that text here, I could probably help you out a bit more.

Hey there, thanks for helping me out.I’ll post my code below(both .cpp and .h) because I’ve already added what you said but that sadly didn’t help.

// Fill out your copyright notice in the Description page of Project Settings.

#include "BatteryCollector.h"
#include "Classes/Components/BoxComponent.h"
#include "SpawnVolume.h"
#include "Kismet/KismetMathLibrary.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;

	// Create the box component to represent the spawn volume(area)
	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::GetRandomPointInVolume()
{
	FVector SpawnOrigin = WhereToSpawn->Bounds.Origin;
	FVector SpawnExtent = WhereToSpawn->Bounds.BoxExtent;

	return UKismetMathLibrary::RandomPointInBoundingBox(SpawnOrigin, SpawnExtent);
}

// 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 BATTERYCOLLECTOR_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;
    
    	// Returns the wheretospawn subobject
    	FORCEINLINE class UBoxComponent* GetWhereToSpawn() const { return WhereToSpawn; }
    
    	// Find a random point within the BoxComponent
    	UFUNCTION(BlueprintPure,Category = "Spawning")
    	FVector GetRandomPointInVolume();
    
    private:
    	// Box component to specify where pickups should be spawned
    	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Spawning", meta = (AllowPrivateAccess= "true"));
    	class UBoxComponent* WhereToSpawn;
    	
    };

Hopefully you can help me out again :smiley: ! Thanks in advance.

I can’t find the problem. Can you do what arrpeatwo4 asks for or upload the project, so it’s easier for people to just go straight in without recreating the tutorial? <3

You put a semi-colon at the end of a UPROPERTY( ) macro:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Spawning", meta = (AllowPrivateAccess= "true"));
class UBoxComponent* WhereToSpawn;

Change it to:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Spawning", meta = (AllowPrivateAccess= "true"))
class UBoxComponent* WhereToSpawn;