Variables from C++ not showing on BP

Not sure what I am doing wrong. I want to write the level script via C++ and Blueprints, but when Im declaring a variable, it only shows up on the defaults tab and I can’t edit it on the graph.

My .h

UCLASS()
class ASurvival : public ALevelScriptActor
{
	GENERATED_BODY()
public:
	ASurvival(const FObjectInitializer& ObjectInitializer);

	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Variables")
		int32 Nights;

protected:

	virtual void ReceiveBeginPlay() override;

	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

	virtual void Tick(float Delta) override;
	
};

I’ve tried setting to BluePrintReadWrite and is not working. I’ve followed many tutorials of how to make your C++ variables show up on BPs but is not working for me.

Im using 4.7.5, Win 8, running Development Editor

Are you talking about the main blueprint or when you change individual instances via the viewport?

I have :

try to change GENERATED_BODY()
to
GENERATED_UCLASS_BODY()

    UPROPERTY(Category = Move, EditAnywhere, BlueprintReadWrite)
    float rotadd;

I guess is the same , just different order, then i initiate them in the main cpp file class like:

rotadd = 0.0f;

have you tried recreating the blueprint and attaching it to the class again? blueprints tend to get corrupted pretty easily when you change stuff in them via C++ I found.

I changed it to the UCLASS_BODY and the variables still on the defaults only, I can’t drag it to the event graph to manipulate it.

There no variables supported in level blueprint (i don’t know why, but it is like that), if you want to edit variables of ALevelScriptActor you need to create variables to do so, or you may able to edit varables by making node that returns ALevelScriptActor of a level:

ALevelScriptActor* GetLevelBlueprint() {
                  
     if(GEngine) return GEngine->()->GetLevelScriptActor();
     return NULL;

 }

If you want to set default variables which work like meta data of the level, there better class for that, it’s called AWorldSettings

As names states, it is class responsible for world settings in editor which contains settings of level (you can find it in “settings” in main toolbar), you can actully extend that, it works like default properties, “EditAnywhere” will make it appear there, . It also works same as level blueprint (ALevelScriptActor), all settings set there will be stored in level. Problem is it’s not exposed to blueprint either so you need to also create node to use it in blueprint

AWorldSettings* GetWorldSettings() {
                  
     if(GEngine) return GEngine->()->GetWorldSettings();
     return NULL;

 }

NICE! This was useful