Custom item or class database

Hi all,

I’m looking to create a database that contains all the data I need for constructing certain gameplay elements at runtime. Preferably editable via a blueprint, for easy access and changes.


Example:

I have a Weapons and when the weapon is equipped I can query my item database and access the properties of the weapon.

  1. Name
  2. Type
  3. Damage
  4. UStaticMesh (mesh)
  5. ParticleSystem (Special FXs)
  6. etc.

Attempted:

I tried to create a Database class that held a TArray of my ItemData class. Then creating a Blueprint of the class.

The theory being, that I could have an array of my data class, then populate the array with all the data and references, such as, meshes and particles systems as needed. However, it seems you cannot have a TArray of classes.

So then I tried creating a Struct for my ItemData and using a TArray of those, but that also seems you cannot populate a struct with a TSubobjectPtr. If you do it crashes the editor.


Question:

So my questions is how would I go about setting up some kind of database as described? Or is there something I am missing?

What are you trying to use TSubobjectPtr for in the structure? TSubobjectPtrs are meant to point at actor sub-object, as name says as well. It should not be used anywhere outside of the actor.

Just hold asset references in your structure.

Have you tried SQLite? I’ve gotten it to integrate pretty well with unreal.

What would i use to hold the reference and still be able to choose it nicely from the content browser? I’m attempting to make a very user friendly interface so anyone can add items and spells etc. I used TSubobjectPtr as an example because I like how it displays in the details panel. I like how you can select items that the class will spawn such as when you use it in conjunction with UParticleSystemComponent to select what particle system will be used with the actor.

I have looked into it, but my plan it to create something use friendly within the editor for other team members to work with.

I did some more digging around and found FStringAssetReference and TAssetPtr to be the answer to my issues.

Here is the documentation:

and here is a great tutorial someone did on the forums: