I’m doing the intro cpp on unreal engine but i’m having a problem when i’m trying to build the project on xcode.
i get the error:
Setting up Mono
Building IntroCPPDocs...
Compiling with Mac SDK 10.10
Parsing headers for IntroCPPDocs
/Users/marchiore/Documents/Unreal Projects/IntroCPPDocs/Source/IntroCPPDocs/MyActor.h(13) : Error: In MyActor: BlueprintReadWrite should not be used on private members
Error: Failed to generate code for IntroCPPDocs - error code: OtherCompilationError (2)
UnrealHeaderTool failed for target 'IntroCPPDocs' (platform: Mac, module info: /Users/marchiore/Documents/Unreal Projects/IntroCPPDocs/Intermediate/Build/Mac/IntroCPPDocs/DebugGame/UnrealHeaderTool.manifest).
Command /Users/Shared/UnrealEngine/4.7/Engine/Build/BatchFiles/Mac/RocketBuild.sh failed with exit code 2
Looks like your variable is not in the “public scope” (google: public private scope C++).
A basic fix would be to add “public:” on the line above your UPROPERTY but it’s possible something else is also wrong because I think the normal unreal macros leave everything public.
// Fill out your copyright notice in the Description page of Project Settings.
#include "IntroCPPDocs.h"
#include "MyActor.h"
// Sets default values
AMyActor::AMyActor()
{
TotalDamage = 200;
DamageTimeInSeconds = 1.f;
// 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 );
}
MyActor.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class INTROCPPDOCS_API AMyActor : public AActor
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
int32 TotalDamage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Damage")
float DamageTimeInSeconds;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Transient, Category="Damage")
float DamagePerSecond;
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;
};