I want to have many complex objects of the same type in a level. They don’t need to exist at the same time and they are visited in a strict pre-defined order but can be revisited if traversing the level in the opposite direction. Only a single one is “active” at a time. I want to be able to position them in the editor and tweak their properties when I place them. Examples would be cameras, trigger volumes.
What would be the best way to do this in UE5?
I don’t want to create them all at the start of a level if only a single one is active at once. At the very least I don’t want them to tick. Ideally I would have a data structure of the properties and then a single instance of the actual object which takes on the properties of whichever element it needs to. Keeping track of an index in an array or a pointer in a linked list would allow me to traverse and switch the data as needed.
But how can I get the data of things I place in the editor? Is there a common approach to this problem?
To keep data structure for properties look into Data Assets (there are C++ ones and blueprint only).
You can also create blueprintable component, then drop those on actors in level, a bit of platter code to hook with actor. And i am not sure if blueprintable component can have other components like trigger volumes.
If blueprintable component does not work you can try blueprint class inheritance. Make parent/base class that has all code, then do child classes that have just gameplay visuals.
Anyway parent class (or blueprintable components) should:
hook to dispatcher in place like game instance, game mode etc.
set own ID (integer they read from game mode, increase, remember and update in game mode)
gameplay tag, that defines type of of this actor instance.
based on gameplay tag it can read Data Asset that holds all settings
and finally you set settings manually, give actor New gameplay tag, and have script (event) that can be triggered from editor and save all settings to new data asset.