Get Variable Values from Class (or How to Control Spawn?)

Hi All!

What I want to achieve: I want to filter which classes of weapons to spawn randomly at the beginning of the level. However, the player should be able to restrict the weapon types to be spawned. This info is stored as a custom variable inside the weapon BP.

What I am currently doing: I have created a DT containing all weapons by class (+ other info that I typed manually even though it is stored in the BP itself) and add all classes to an array to iterate through later on.

Any ideas of how I can access the BP variables from just the class (or link the variables in the DT itself?) or how to make this process more efficient / leaner?

Much appreciated!

1 Like

If I understood you right, if you have a ref to any of guns you can easily get any variables of it

Thx for the help, but I haven’t spawned the weapons yet. “Get All Actors Of Class” only returns a reference if the class exists in the level already. I wouldn’t like to add each gun to the world (somewhere under the map) as it is prone to mistakes when I add more guns in the future…

Hope I could make myself clearer this time and thanks for the try :slight_smile:

You also can use data tables to rewrite default values of spawned actors

But pay attention to, all variables inside spawned actor(that you want to expose on spawn) must have such properties
UEdt2

Yeah, I am afraid that this is the only way go, right? I want to do it exactly the other way around. Extract the data inside the BPs and store it in a DT. Or not necessarily in a DT, but just access it BEFORE spawning the actor so that I know whether or not to let it spawn…

You can’t write to the DT.

access it BEFORE spawning the actor

Is the actor data modified from the defaults? Accessing class default is straightforward:

image

If the data was modified, you need to save it for each instance - like in a Save Game Object.

3 Likes

Exactly what I was looking for, thanks a lot!

P.S. I was using a general “Actor” Class Reference which didn’t show me MY defaults, just the normal ones. By changing the Class Reference to my main weapon BP, I can assign all children classes and access their shared variables.

1 Like