Can I get the data from a class reference?

I have a weapons database which consists of a structure

-ID
-Class Reference (link to weapon blueprint)

I write the structure with the ID to the inventory, and after the ID I get the class of the thing from the database.

But when I have an ID in my inventory, I need to somehow get the name and data of the Thing.

I have a BP_Comp_Weapon component which contains weapon data.

The question is, how can I get the component’s data without creating it and without attaching it to the ChildActor?

You can get the class defaults with

image

But for anything that has changed values during play, you have to get the info from the actual instance / component.


So I can’t get components from my class without creating an instance?

The data is written in the blueprint and does not change during the game, but it can, but I need the static data of the components from the class.

If this is not possible, how then to implement the inventory, create and hide the object from the player?

I’m confused. Is this not the initial settings for the data?

I need to get component data from Class Reference. And that’s it.
I am using an empty Actor class with one component.
The component has the structure I need, the data of which I want to receive. Not creating an object.
Like in a prefab in Unity.
In Unity, an object may not be created, but you can get all its data from it, and data about each of its components, without creating it.

In Unreal, you can get the class defaults without creating an object, but anything else, you do need an object.

If you are fine with writing C++, what you are doing might be better done using Data Assets
Otherwise, you could always just use a data table with a custom struct that holds the information for all your weapons (basically what you have in BP_Comp_weapon, as well as a reference to the mesh that your weapon uses, which I’m guessing is what your BP_WP_Rifle1_Mesh is.

After that, you can find the row in that data table using your ID, and get the data that you want.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.