copy function from blueprint library to data asset

I have complex functions I have created in a Blueprint Function Library and need to copy them to a Data Asset Class.

I tried to do so, and even removed the world context pin from the function input node, but get warnings still.

It would take considerable time to copy and paste the function nodes not to mention most likely introduce bugs to debug.

Is there any way to copy/move these functions to the data asset?

Hey @blindminds!

Data Assets aren’t really meant to house a lot of complex functions- can you elaborate more?

What are the errors you’re getting, for instance?

What are the functions themselves? What are they intended to do? Typically the functions for a Data Asset will be mathematics, primarily, not needing references outside of the DA.

Let us know some more and let’s work with that new info! :slight_smile:

The functions relate to the data in the data asset, and are complex functions that, using the data in the data asset, build a set of data to return to whatever needs it. An example would be a character profile data asset, which contains the entire history for a characters profile throughout time, but the profile needs to be “built” by the functions using the data conained in the asset, as the data contains commands for how the profile elements are updated throughout the timeline (Append, Replace or Delete). This way I can compactly store an entire history and build the current profile for any given time.

I also have simple Debug Print String functions I use all the time in a seperate blueprint function library. The afore mentioned functions were also contained in a blueprint library.

Copying a function does not work as it return error as shown

I tried deleting world context pin, but still gets error. Only way I have found is to create a new function on the data asset class, manually create input nodes, and then paste the nodes from the other function and re-connect connections.

Is there a way to create a different type of function library?

Do I need to create an Object Class Subsystem, to put all my functions in, have the GameInstance create the subsystem, then call functions from the subsystem reference to get a function library that anything can access?

But I still have to copy paste the functions, because I cannot access the functions from objects.

It does sound like your Object Class Subsystem idea would be more successful- reason being, Data Assets are extremely useful, yes, but they’re static. They’re not really for changing things dynamically like an object would be able to. As such they are limited to the types of functions that are allowed due to lacking functionality… “physicality”, as it were, because they only exist in the game files but not the game world as an object would be.

The nodes and code themselves being offloaded to an object is an old tactic, but still a good, fast, and lightweight one! Especially in Object-Oriented Programming like is used in UE! :slight_smile:

I am not sure what you mean Data Assets cannot be manipulated Dynamically. The Data Assets themselves are static, yes, but I did a test, and if I create a Data Asset at runtime, I am able to set and manipulate variables.

Using Data Assets allows others to create Data Assets that can be read from disk, but also can be used as an object in memory.

The variables can be changed (while the Actual Data Asset on disk can stay static as a permanent default), and then when that Data Asset needs to be saved, I have separate SaveGame Object Classes setup for each (blueprint only, so only way I know how to save them).

To control loading of assets and preventing hard references etc., I was thinking I would have, for example, character class that will hold re reference to all the various data objects (profile, images, history, inventory etc.), this way, say when a profile data section is needed to display in a widget, I can load it at that time, as it may never be needed otherwise, but yet, I can create “hard” Data Assets for complete Characters at development time or DLC packages, and as well, users can dynamically create them at runtime, then save to a save slot, and I can use a naming convention for save slots to append various data objects to a save slot string id - example: EOSUserID_CharacterID_Profile, and then I can avoid loading all of the data at the same time, and only load the characters profile from disk, without needing to load all textures, meshes, images etc. associated with the character.

I am also trying to use Data oriented programming over OOP. So want to completely seperate Data from Functions, except in Data Asset Classes where it makes sense. But I guess now I might as well put everything i nsubsystems and keep data with no functions

The real question, is how can I copy those functions from my blueprint library to the new Subsystem Object Class?

Now that you explain the whole thing in detail… I have to hand it to you, that’s pretty smart, I never thought of using DA’s that way! I’ve run into a lot of people trying to use DA’s that will attempt to treat them as Actors on the Event Graph, and you just… can’t do that, the functionality is limited because while they’re not strictly data-only assets, they’re not much further beyond that.

So I guess my question to you now is, if these functions are in a Blueprint Function Library, why do you need to copy them? What’s stopping you from simply calling them from the BPFL? And instead of a subsystem just using the GameInstance?
I’m asking because I haven’t made moves like this before, using a DA at runtime, I’ve always used them as static data containers to call on, but I have enough context around BPFL’s and DA’s individually that I should still be able to at least point you in the right direction and help you think the problem through.

Because Objects cannot access a blueprint function library, and if you copy the function from he blueprint library directly, and paste into an object class, it will cause an error (as stated earlier).

So, in order for all Blueprints and Objects as well, to b able to access a core set of functions, must be held in an object class that is stored as a variable in the game instance (cause everything can access game instance), but that mean I have to “rewrite” those functions because copy paste does not work.

Only blueprints can access blueprint function libraries, such as game instance, game mode, HUD, actors etc.

Why not make it a blueprint Actor that is placed in each level? Just throw it near the world origin, just a scene node? It would take up a negligible amount of memory. I know a lot of practices use this tactic, such as AI managers or 3D Rendering boxes for inventory items etc.

That way, you could use your BP Function Library as is, and not possibly lose any functionality?

Otherwise, yeah… you’ll have to rewrite them to accommodate Objects. Provided, you are talking about the base C++ class and not a Blueprint Object?

Actors take up a good bit more memory than objects
Using an Actor in middle of each level sounds like a terrible decision to me, I prefer to do things “proper”. That seems overly sloppy, not to mention then it has to be added to every level. I appreciate your efforts to help, but the solution is eaither a clever way of copying the functions or copying the functions :wink:

I am trying to build a good framework, as I am making a program, and not just a game.And as such, it will have extensive modibility. So Objects and Subsystems is the way to go along with Data Assets.

I mean yeah, they do, % wise, but in the grand scheme of things with today’s hardware it’s usually an amount that would be negligible. BUT- I get what you’re saying, with your use-case I can understand the need for minimal memory usage, it might be somewhat on the fringe for most UE users but it is very valid for advanced programmers.

That being said- if copying is the requirement then yeah… Subsystem. That or put everything on the GameInstance WHICH I don’t think is a bad idea. It’s always loaded, the fact that you’re using savegame objects to store the data means the nature of the GameInstance being deleted and rebuilt on restart means it won’t get bloated with variables if you do regular “purges” of the memory by utilizing those savegame objects… Otherwise yeah, you’re going to have to rewrite nearly all of that code just because it is Object-oriented.

I do not want it in the GameInstance because i want modular code, that can be easily copied from one project to another, like a plugin, without being a plugin. This is the wonderful thing about programming, I can build a large web of small frameworks, each of which can be used in different projects as needed. I have a game I was doing that had large use of physics equations for fuel consumption etc., but the code is all in blueprint function libraries. I should have made a subsystem using objects, the ni could “port” it too other projects. Only real downside i see is that subsystem has to be referenced to call from, where as blueprint function libraries can just be accessed through the right click menu.

An example, is my current project I have a panel framework (basically a cheezy version of windows, but not scalable) I built for the UI, and I can move it from project to project to reuse the functionality