Search code examples
unreal-engine4unreal-blueprint

Is it possible to create a function that returns a different struct based on an enum input in Unreal?


So I am working on a data driven game in Unreal and essentially I am working more on the back end trying to make it easier for the objects to get all of the relevant data. I was really trying to create a singular function that by passing in a type I could return a different output but, from what I've tried in the editor this doesn't seem possible.

Function with wildcard

I get the error: The type of Out Struct is undetermined. Connect something to Return Node to imply a specific type. I was trying to use a wildcard as an output but, it doesn't seem to be able to do that. Any insight on this problem would be greatly appreciated.


Solution

  • As mentioned in comments, just make base struct and inherit your *Config structs from it. In return you will send base struct.

    You can read more about this solution here: https://en.wikipedia.org/wiki/Factory_method_pattern