[Beginner] My program can't compile


I’m just beginning in UE4 and tried to follow this tutorial.

Therefore, he was done in a older version of UE4, so i had to change some of the lines of this tutorial. My problem is that the code don’t want to compile, I an ouptput that could be traduced like that:

Parsing headers for TestUE4Editor
1>  D:/Programmation/TestUE4/Source/TestUE4/PickUp.h(26) : BlueprintReadWrite should not be used on private members
1>Error : Failed to generate code for TestUE4Editor - error code: OtherCompilationError (5)
1>  UnrealHeaderTool failed for target 'TestUE4Editor' (platform: Win64, module info: D:\Programmation\TestUE4\Intermediate\Build\Win64\TestUE4Editor\DebugGame\UnrealHeaderTool.manifest).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""D:\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" TestUE4Editor Win64 DebugGame "D:\Programmation\TestUE4\TestUE4.uproject" -rocket" stopped with the code -1.

I have those errors :

Error	1	error code: OtherCompilationError (5)
Error	2	error MSB3073: The commande ""D:\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" TestUE4Editor Win64 DebugGame "D:\Programmation\TestUE4\TestUE4.uproject" -rocket" stopped with the code -1.
Error	3	IntelliSense : No instance of the constructor "APickUp::APickUp"match with the list of arguments

As the IntelliSense Error let suppose, i think it’s an error related to my constructor of the class. Therefore, I actually use the right prototype, so it’s really bizarre.

There is my class:
Header :

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

#pragma once

#include "GameFramework/Actor.h"
#include "PickUp.generated.h"

class TESTUE4_API APickUp : public AActor
	APickUp(const FObjectInitializer& ObjectInitializer);
	// Sets default values for this actor's properties

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	UPROPERTY(EditAnywhere,BlueprintReadWrite, Category = Pickup)
	bool isActive;

	UPROPERTY(VisibleDfaultOnly,BlueprintREadOnly,Category = Pickup)
	USphereComponent *Collider;

	UPROPERTY(VisibleDfaultOnly, BlueprintREadOnly, Category = Pickup)
	UStaticMeshComponent *PickupMesh;

	void OnPickedUp_Implementation();

Class :

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

#include "TestUE4.h"
#include "PickUp.h"

// Sets default values

APickUp::APickUp(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
	isActive = true;
	Collider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("SphereCollider"));
	RootComponent = Collider;

	PickupMesh = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("PickupMesh"));
 	// 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;

// Called when the game starts or when spawned
void APickUp::BeginPlay()

// Called every frame
void APickUp::Tick( float DeltaTime )
	Super::Tick( DeltaTime );

void APickUp::OnPickedUp_Implementation()

Do you know where the error(s) come from and how could I solve them ? That said, do you know tutorial with a version of UE >=4.6 to begin more easily ?

Thank you for your help, and I really apologize for my poor English… :slight_smile:

UPROPERTY’s using the BlueprintReadWrite tag cant be private members of a class. They have to be protected or public. You should be fine moving your isActive property to the protected members, or changing it to BlueprintReadOnly

I just wanted to say awesome job posting your code and your errors straight up without needing to be asked! You my friend will go far :slight_smile:

Haha, yes, I used to help on a C# forum so I know, it’s something very annoying when you just see “I HAVE AN ERROR PLIZ HELP!!!”…

When I move all my UProperties into a protected member, it works.
Another error that If I have a function ; Myfunct_Implementation(), I must declare this Myfunct() in my header (and not Myfunct_Implementation()).

My problem is solved, thank you :slight_smile:

By the way, is there a way to declare theses properties/functions private and not protected?

Hey there Maxime, Glad to hear it worked out. I apologize for missing that function at the bottom, I failed to scroll down the code.

You can declare these as private, but the UPROPERTY tags have to reflect that it cannot be directly modified. Here is a UPROPERTY I have that is a private member:

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
	class UCameraComponent* SideViewCameraComponent;

The meta tags all just have this is as visible and not editable. When I need to edit this, I have a separate public function thats a getter:

FORCEINLINE class UCameraComponent* GetSideViewCameraComponent() const { return SideViewCameraComponent; }

that lets me modify the property. This is the method the engine prefers, and thus limits the Edit tags of Uproperties to be public or protected.