"Solus project" example

Trying to mimic some demonstrated simplifications in Solus project to make variable (or Property) be accessible in any BLueprint in a project.

To understand what I want please watch the video from Hourences’ official channel from 6:33
The Solus Project: Application of Unreal Engine 4 - Part 3 - Closing Words

What I did is:

  • Added code to project - Actor
  • Added simple code:

.h

/** What is the Player's current musical skill level? */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = PlayerMusicSkill)
int32 MusicSkillLevel;

.cpp

MusicSkillLevel =66;

If you have a C++ based project I recommend creating your own actor deriving class in external text editor and then compiling in Visual Studio, or using VS the whole way.

Once you’ve done that post the full code of your actor extending class that you’ve made!

They simply created functions that set and get variables

.h

//removed BlueprintReadWrite as we don't need it anymore as we making functions doing the same
UPROPERTY(EditAnywhere, Category = PlayerMusicSkill)
int32 MusicSkillLevel;

UFUNCTION(BlueprintCallable, Category = PlayerMusicSkill)
void SetMusicSkillLevel(int32 NewPlayerMusicSkill);

UFUNCTION(BlueprintPure, Category = PlayerMusicSkill)
int32 GetMusicSkillLevel();

.cpp

void SetMusicSkillLevel(int32 NewPlayerMusicSkill) {
     PlayerMusicSkill = NewPlayerMusicSkill;
}

int32 GetMusicSkillLevel() {
     return PlayerMusicSkill;
}

Thing is if get and set functions do only this they are pointless as you can do the same just by using variable alone and just by using BlueprintReadWrite. Or else you want to add extra code that react on variable set or get, doing functions like that is only way to achieve that as C++ font have properties like C#;

CPP:

#include "tut1.h"
#include "GlobalVars.h"


AGlobalVars::AGlobalVars(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

}

void AGlobalVars::SetMusicSkillLevel(int32 NewPlayerMusicSkill) {
	PlayerMusicSkill = NewPlayerMusicSkill;
}

int32 AGlobalVars::GetMusicSkillLevel() {
	return PlayerMusicSkill;
}

.h

#pragma once

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

/**
 * 
 */
UCLASS()
class AGlobalVars : public AActor
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(EditAnywhere, Category = PlayerMusicSkill)
	int32 PlayerMusicSkill;

	UFUNCTION(BlueprintCallable, Category = PlayerMusicSkill)
		void SetMusicSkillLevel(int32 NewPlayerMusicSkill);

	UFUNCTION(BlueprintPure, Category = PlayerMusicSkill)
		int32 GetMusicSkillLevel();
	
};

Maybe this can help
A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums!

Did you check libery

Found the solution here A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums!
It’s your authorship
But I’m not sure with frase “You just put all your static functions into a single class!”.
How to do it exactly? What I’ve done: created a new Actor class from Editor (Add code to project). Compiled it (without it we won’t get YourClass.generated.h). Then put your code in there.

Thanks

Thank you for your help!
Now I know how to make functions )