How can I save different functions so I don't have to write every function in my BP?

Funtions dont override but event do if i’m not mistaken, you could create dummy event on itemtypes and then override event on diffrent types.

Hey,

i got a struct array for my items, that saves every important value. Its working well, but i know that i can’t save functions in it while using the struct in blueprints.
Is there a way to save different functions so that i don’t have to write every function in my character blueprint?
I can’t save the object itself, because i destroy it and after 60 sec the pointer would be lost.
At the moment i just check what type the item is and use a function in my character blueprint for each itemtype (food->eat, weapon->attack, cloth->equip). But i don’t really want to save these in my character blueprint. I would like to have a OnUse function on my items and just use them so i dont have to check for types etc.

I only have one main ItemClass and my Blueprints are different childs of it.
ItemClass->Food->Apple
ItemClass->Food->Tomato
ItemClass->Cloth->Backpack

and so on.

So i can only create function in the first child of the ItemClass. I did this till now, but since i can’t save the whole Object (garbage …) it can’t save it’s function.

If i can’t i will go on and use my character blueprint to just differe the itemtypes and use a function for each…

Can i use a function of an unspawned blueprint? So that i would just look what Class my item is and use the function of the blueprint? Than i could set up my function in the ItemType Blueprints again and check the Item i want to use for its class and use the matching blueprint class.

From what I understand (I think), you want to expose USTRUCT() functions back to blueprints.
That is not possible. Only UCLASS (which essentialy means UObject) can have exposed functions back to blueprint.

If you want to have functions which operate on data in USTRUCT() you have 3 options (depends on where you want to use them).

Write functions in C++ in object that is using struct.

Create special object, which will encapsulate struct, with needed functions. You will need then to instance this object, in any object you wish yo use those functions.

If you need these functions only inside editor and not in game, you might be fancy of creating custom property editor for this struct.

USTRUCT() in UE4 world is treated as POCO class.

Hi eXi,

We haven’t heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you’re still experiencing this issue, please feel free to post back here.

Thanks, TJ