Event begin play doesn't fire

I have created this script in Open Level Editor.

The variable inside the UserProfile class is not empty.
The gamemode override is set to MyProject2Gamemode.

The parent class is UObject.

I just tried and it works for me (in 4.22). Is the parent class of UserProfile an Object?

I have also watched [this video][1] maybe it will clear some things out for you.

281554-printstrings.png

Can we see that variable from the object please?

Apologies, I don’t know C++. I thought you are working in Blueprints. But since it worked for me inside blueprints I would have to assume there’s a error somewhere inside C++ code. Maybe someone with C++ knowledge can help you out.

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "UserProfile.generated.h"

/**
 * 
 */
UCLASS( Blueprintable, BlueprintType )
class MYPROJECT2_API UUserProfile : public UObject
{
	GENERATED_BODY()
	
	
public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Stats)
	float Armor;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Stats)
	float HpMax;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Stats)
	FString Name;

};

This is the example in the book “Unreal engine 4.x Scripting with C++”.

Yeah, I don’t think this has anything to do with the Event Begin Play not firing. And to be sure, stick a print just after it to check.

I’d say the issue is that your name variable is coming back empty or just null. It’s got to be a problem inside your class. The name variable is set to something by default inside your class, yeah?

Also, you’re converting a string to do a print text. Just curious why you’re not just using print string.

Did you happen to check if Event Begin Play was firing a print string before your construct node? To verify that this is an issue with your C++ and not blueprints? If so, you may want to try posting this again with a better title, and under C++ since it doesn’t seem to be related to blueprints, nor the Event Begin Play node.

Also, I’m really really bad at C++, but in the snippet you posted, I don’t see anywhere where you’re defining or setting the “name” variable, just declaring a variable. That would explain why the print isn’t actually printing anything. If there’s no value set then it’ll just print an empty string.

I have to call the blueprint class not the C++ class.
Sorry I misunderstood what the book said.
Thank you for your help.