So i am attempting to create a system where the player can manipulate the behavior of an actor, in this case through widgets. The widgets can be dropped in a list and reordered freely and holds various variables that the player can manipulate and when it is time to apply the variables (and thus the behavior) to the actor, I currently pass an array of widget references to the actor which loops through them.
However, since the widgets can be manipulated at any time (and the array is processed over time, not in one frame) direct widget references does not work.
Edit; actually I worded the title wrong. It’s not ‘many’ variables that needs to be passed but rather the variables that needs to be passed could be of many different types depending on the widget.
So what is a good method? Right now I am thinking of creating a big structure, where each widget passes its variables (and probably an enum to know which variable to handle) to a struct which is added to an array, which is then passed to the actor for processing.
But I am thinking; is that wasteful? I mean, it could be a struct with 50 variables, of which only one would be used for each element of the array. So is there a better way? Or is that a common thing to do?
I also thought about, instead of having the actor class have a bunch of functions, create a class (probably UObject?) that does that one function. But that would lead to having a large amount of classes having to be created (both manually and created/spawned during runtime). Or maybe that is a non-issue? Even if UObjects may not affect performance much, I’m not a fan of leaving them lingering in the void after their one-frame use; i’d like them destroyed which seems a bit tricky to do.
Maybe there are other methods?
If there is a tutorial, detailed document or anything about anything related to this kind of stuff, I’d appreciate if they were mentioned. And any suggestions or pointers are welcome.