BlueprintReadWrite should not be used on private members

Ok so I’m following the ever so helpful youtube basic programming guide:

I’m also on a mac. And when I try and build my project I get an error saying:

“BlueprintReadWrite should not be used on private members”

The line it refers to is in the header file for my pickup class seen below:

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

#pragma once

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

/**
 * 
 */
UCLASS()
class MY_GAME_API APickup : public AActor
{
	GENERATED_BODY()
	
    //this bool variable is active inside the editor; can edit in blueprint editor with the macro here.  True when able to be picked up, false otherwise
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Pickup);
    bool bIsActive();

Now I’m not sure if this is related but I’m also getting errors saying “UnrealHeaderTool failed for target [MY_GAME_NAME]…” and it ends with “…UnrealHeaderTool.manifest”

and

RocketBuild.sh failed with exit code 2.

Any help would be appreciated.

It says it’s missing the variable type in that line. Which variable would it be referring to?

Yeah I did, same issue though. The compiler is saying the issue is in the line with the UPROPERTY.

With GENERATED_BODY() by default all the variable is private, so you must add public: before it something like this

GENERATED_BODY()
public: 
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Pickup);
bool bIsActive;
1 Like

did you change your bool bIsActive(); to bool bIsActive;

You have a trailing semicolon after your UPROPERTY.

Ok so that was it. But now I’ve run into a series of other issues. That intro video to UE4 where the Pickup class is created is definitely outdated. Does anyone know where I can find amore updated version of that by any chance, maybe something that goes over the basics of all the classes, macros, etc?

In UPROPERTY(…) you can add the argument meta = (AllowPrivateAccess = "true") to allow access of private variables from blueprints. This will fix the “BlueprintReadWrite should not be used on private members”.

So in your code, it would be:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Pickup, meta=(AllowPrivateAccess = "true"))
bool bIsActive;
2 Likes