Error when trying to compiler simple class

I’m following along with the tutorials provided by unreal and I get the point in the code where I’m trying to create properties to be adjusted in the editor. My code is as follows:


#pragma once

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

UCLASS()
class MYPROJECT3_API AMyActor : public AActor
{
	GENERATED_BODY()

		UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Damage")
		int32 TotalDamage;
	
	
public:	
	// Sets default values for this actor's properties
	AMyActor();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	
	
};

and I haven’t even touched the implementation file of:


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

#include "MyProject3.h"
#include "MyActor.h"


// Sets default values
AMyActor::AMyActor()
{
 	// 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 AMyActor::BeginPlay()
{
	Super::BeginPlay();
	
}

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

}


The error message I receive is:

Error 2 error MSB3073: The command ““C:\Program Files\Epic Games\4.9\Engine\Build\BatchFiles\Build.bat” MyProject3Editor Win64 Development “C:\Users\Documents\Unreal Projects\MyProject3\MyProject3.uproject” -rocket -waitmutex” exited with code -1.

I do not know how to fix this. I have both visual studio 13 and 15 on my system but obviously as of now unreal engine only supports 2013 full so that is what I’m using. Also I’m using version 4.9.2

That’s not the real error message. Look for something else, or check the output log files and come back and post it in this thread.

But just from looking at it you cannot have the private variable ‘TotalDamage’ declared as blueprintreadwrite, it must be public.

it doesnt have to be public

without telling which access modifier you use (public/proteced/private) its set to private by default.

If you want to expose it in a blueprint which is some kind of child of your class you would need to set it at least to “protected”. “public” will work as well, but its bad habit to expose variables as public use getter instead.

When i said “some kind of child” means you can also expose private variables
with a meta specifier inside the UPROPERTY.( i just dont remember it, something like “meta = AllowPrivateAccess” or something)
I just learned that myself :slight_smile:

Put “public:” before the two lines that define TotalDamage.

Also for future reference, please include the full error dump when asking for help on the forums. The error you supplied is the root error, not the cause of the error. You must look through the compiler’s output to suss out what the actual cause of error is.

Okay, thank you guys for your responses. I didn’t realize what I posted wasn’t helpful. I will remember that in the future. Anyhow I got things to work by doing what a couple of you have suggested and put UPROPERTY()int32 TotalDamage in public: instead of private:.