Add instances of actor to array
I'm working on a realtime open world campaign game, where the world is divided into several regions. Each region then has its own flags which the team needs capture in order to capture the whole region. I have an actor class for both the region and the flag, and what I want to do is add instances of flags placed in-game to the region they belong to. Hope this makes sense..
Although, I know I could just give each flag inside of the region a unique ID, and loop through all of them in order to get the number of flags captured, etc. But my question is if it is possible for me to add the instances of all the flags inside the region-actor to an array belonging to the region-actor? That way I could easily get an element of the array and access capture progress, owning team, etc. directly from the region-actor and everything would be so much easier!
Please notify me if something is unclear, this functionally of the game is basically what it's all about, so I'll do my best to make this understandable.
Thanks in advance! :)
asked Jul 11 '18 at 08:54 PM in C++ Programming
I would probably have one array in the game mode or somewhere similar which tracks all flags, so as they are spawned they are added to that array.
For me, the array would probably be a type AFlag which inherits from AActor, or it could be a struct or a simple class. In either case you should track
You could also use a TMap or a TSet depending on exactly what you want.
You can now perform simple loops through the list / set / map which will allow you to check how many flags exist and how many of them have been captured etc.
Follow this question
Once you sign in you will be able to subscribe for any updates here