Is it bad to use maps where the order of the keys/values matters?

I’m making a game where i use maps to store numbers and actors. The numbers however must be in order for the game to work (but not including every number). For example:

1 - actor
5 - actor
8 - actor

Would work but

1 - actor
8 - actor
5 - actor

Would not. Is this bad? Is there any risk of my maps getting reordered if I always set them up in order? Is there a way to reorder them?

its fine if you control it,

A. you could spawn them in order inside the GameMode or something,
B. you could assign them a int value and set them manually

but if you rely on BeginPlay then orders can be messed up

I fill the map by reading of components of the actor so the order of them matches the order of the components of the actor. Once the map is set, theres no chance of it getting messed up right?

Map or Array? you could just use an Array and SetArrayElement so you can choose the index.

Reading components could be problematic if you change components which then changes its index

The map has no order; you can’t rely on the order you see them displayed in the editor at all.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.