Get anothers actors variable

I have a class called “LevelDatabase”, and in there several settings are stored. The one I need to access from a different object is the FramesPerSecond setting.

So I have a Blueprint class named “LevelDatabaseActor”, and a C++ class called CustomCapture. The game has one instance of the LevelDatabase, but possibly several captures. Now at the beginning, in the BeginPlay() of CustomCapture, I want to access the FramesPerSecond setting from the LDBA. How can I do that? I wanted to try with a blueprint to make it an exposed variable in C++ (BlueprintWriteable), but the GetAllActorsOfClass in BP and then get only returns copies, not references, so the value wouldn’t be set there.

How can I access another objects variable from C++, or in the BeginPlay() function read it from the BluePrint actor?

Evne with blueprint using GetAllActorsOfClass is last resort. You either spawn them and keep the returned variable or make actor register themselves (pass the the pointer to it self) to GameMOde or whatever object that is al to easier to access.

But in case you described there something 10 times better then all of this. You are aware “World Settings” that are saved with the level? What if told you in reality it’s property of actor that editor includes with the level to keep those world settings, and you can make you own class with your own properties and use it same as you do with GameMode? :stuck_out_tongue:

So class is called AWorldSetttings, create your own based of it, add properties that you want to add settings to World Settings (it behaved same way actor properties and defaults, so you do EditAnywhere and set proper Category you desire in UPROPERTY specifier) and then in project settigns search “World Settings Class” and set to yours. Now alll World Settings in project will have extra property you declered in you class will be saved with the level and you can easily access it in C++ using function in every actor!:

No need to keep any pointers no need to do any searching or registering, no need to place actor on the level, everything is nicely integrated with the editor UI :slight_smile:

Okay, I tried doing that, and did following: // Fill out your copyright notice in the Description page of Project Settings. - Pastebin.com

In the world settings details though the frames_per_second never shows up. Why is that? I changed it in the project settings to use RTW_WorldSettings as WorldSettings, but I have not noticed any difference, and in the search “frames” show some other results, but not my fps setting.

Okay, got it. But how can I change that FPS value from the UE4 Engine itself, without hardcoding it in the cpp file?

I have no idea what I did different, but now it suddenly shows up. I swear I did nothing except recompile like a few dozen times… thanks, works!

if you have wierd thing like that compile without editor opened. rebuild if still not working. Most reflection system issues is caused by hot reload