Getting Asset User data on PCG graphs

Hello PCG people!

We are currently trying to evaluate on our project some ways to set parameter overrides like disable WPO distance or Cast Shadows on assets in the content browser and then capture those values and change the parameters set in the Spawn Static Mesh template descriptor. We initially set those values on PCG blueprint actors but any time a value needed to be changed we would need to update a whole lot of actors manually. Obviously defeating some benefits of using PCG by forcing lots of rote work.

So, long story short, we are now evaluating if it’s possible to set values and parameters in the Asset User Data and get those parameters that are associated to each mesh in PCG. Is this workflow supported with the current nodes offered in PCG? Is this workflow sane or considered as good practices by UE developers? I’ve done a cursory search but haven’t found a node that can get us that data. I’d like to make sure this type of workflow makes sense so that we can simply set the values and options on the asset instead of the actors placed in the game as that’s the only way we have found to set those values currently.

Hi Francis!

If the workflow of Asset User Data is sane or not, I could not say, I didn’t know it existed before you mentioned it.

From what I’m seeing, I don’t think it is possible with existing nodes, because Asset User Data is not stored as a UProperty on an asset.

And I tried to see if I could do it in a custom BP node, but unfortunately, `UInterface_AssetUserData` is not usable in BP. There is a function to get it, but no way to cast it (since `UInterface_AssetUserData` is an interface, I thought I could just cast it from the Static Mesh asset, but it seems BP doesn’t allow it).

So your only option here is a custom C++ node.

The node would take as input a list of assets to get the data from, and potentially a class of AssetUserData to read from. Then you can just cast it in your node and read the values and write the result into an attribute set. If you made the AssetUserData customizable, you can use `PCGPropertyHelpers::ExtractPropertyAsAttributeSet`, which will extract everything in the asset user data, as long as those properties are UProperties.

You can have a look at `UPCGGetPropertyFromObjectPathSettings`, this would be very similar, but instead of extracting the object itself, you would get the asset user data from this object then throw it into `PCGPropertyHelpers::ExtractPropertyAsAttributeSet`.

I’ll make a Jira on our end to implement this kind of node.

If you need more pointers, don’t hesitate

Adrien

Thanks for the investigation on how it can work Adrien, I appreciate it!

To give further context (and perhaps see if you have some ideas on how we should generally tackle the problem) i’ll expand on what is going on:

We had an issue where we had lots of assets that needed to have WPO disabled or shadows disabled at a certain distance. However it isn’t possible to set those values on the asset itself. Users really need to place the asset in a level and then they can change those parameters. meaning lots of rote work. So we thought of having each asset in the content browser have some values set on them in a way similar to houdini that can then be distributed all over the place (manually or procedurally).

We have investigated, on the procedural side of things, the idea of using PCGDataAssets with attributes that can override the spawn static mesh descriptor parameters on them. However, problems would immediately become apparent when some users would place static meshes from the content browser directly as those actors would not have the same parameters set on them as the PCG spawned Instances.

I wonder if you could have some kind of manager on your map that would listen to any static mesh added to the world, that would read your Asset User Data and would set those values. That could be the role of a subsystem for your project. But this should probably only track static mesh actors added manually, and not the one procedurally generated. You can look for tags on the actors/ISM components, PCG add tags on them, so it should be easy to filter them out.

On the PCG side, you duplicate the code of the node “Get Property From Object Path” in your project, and adapt it to read the Asset User Data on the object instead of the object itself, and override the static mesh descriptor. Note that I have created a task on our side, should be straight forward to have this for 5.8.

It’s an idea on the top of my head, it will need to be profiled and verify it is a viable option hehe :slight_smile:

Adrien