I use some generic struct FDataStruct to keep track of all character data: name, HP, inventory, and so forth. I’d like to curate the data for every character in the game in a single, centralized TArray, and only give characters spawned in the world an int ID they can use to find their character’s data in the list.
The easiest way to manage IDs seems to be to make the index of the array in which a character’s data is held their ID, so you could access it from anywhere in the game by calling LogicActor->CharacterList[ID].
What I’m wondering is, is there any reason not to do it this way? Assuming I stored a copy of the index inside the data struct (so I could rebuild the list if an index accidentally gets deleted), I’m not seeing a downside to this method, but as I’m self-taught and still a very basic programmer, incredibly obvious stuff has a habit of not occurring to me.