Is it possible to have an array asset that I can simply reference in my blueprint and get all those assets instead of having to reference each of them for every blueprint?

So basically, I want to do an action in a bp and the action would play a random sound file.

But there are a lot of sounds and there are alot of different BPs so referencing each sound in each blueprint one by one is kind of time consuming and I’m quite sure, costly on performance.

So is there any way for me to create a type of array asset in which I could reference all my sound files and just reference that array asset in each BP?

CREATE ADVANCED ASSET > BLUEPRINTS > STRUCTURE
should work

2 Likes

I’ll look into it! Will update what happens! Thanks!

OK so this will definitely work! But how do I reference a struct inside a BP? Google keeps showing me definitions for it.

EDIT: nvm stoopid me. Just had to create a new variable and change it’s type and in the list of types, my struct was showing right there as bright as day.

there’s more stuff like this you can use, one is called datatable, another is udataasset, i’m not sure how good they work with bp though, i think struct is the best one

1 Like

You can also create function that reads those sound references from array given action enumerator (or name as string). Create function library, put that function in there, and you can use it in any blueprint. However be careful make only one function library its very easy to create circular dependencies with multiple libraries, and it is pain in a. to fix it later.

For prototyping stage of your game all can be contained in that function.
Then you can upgrade this, put array in blueprint like game state game mode etc.
And last stage would be coding in C++ function that reads db or text file and fills that array from it.

Start small, you do not need (yet) whole system with database or xml\json files etc.
All you need is some function + array that can feed some data to your sound system.
You will change all that data multiple times during development.

For referencing structs\enums etc, use prefixes, for eg i name all my structs with prefix MyStruct_
enums as MyEnum_, then create variable and change its type to MYWhatever_ i need now.
When you want reference struct in another bleuprint, gets its pointer (get all actors of class, then read array[0]) then cast to class of that blueprint and you can reference variable by name does not matter if its integer struct or something you created.

2 Likes

Just use a data asset. To create a data asset:

  1. Add New → Blueprint Class → PrimaryDataAsset.
  2. Add variables (like your array of sounds) to the class. If you set values here, they will be the default values for that data asset.
  3. Add New → Miscellaneous → Data Asset, and pick the name of your data asset class.
  4. Open it up and set the values.

To use that data asset in a class, add a variable of your data asset class and set it to the data asset you want (you can have multiple data assets for a data asset class).

2 Likes

Yes I looked into Data Assets and I think they require you to have a C++ project to use…?
Well anyways, my work was easily accomplished with the Struct, and I learned to use a new asset so yay! Thank you to all!

wow that’s one way to do it I guess… Kind of a long road tho as opposed to a simple Structure. Structs got my stuff done in half an hour, which otherwise would have taken 2 to 3 days!

I think I’ll look into data assets once more…