I have a variable the stores the state of the player. In order to prevent excessive string compares every frame cycle (i.e. myState == “flying”), I’ve stored everything in an array (i.e. var.flying = 1, var.ground = 2, etc).
I would like to take it a step further and ask, which is more efficient?
var.flying
or
var[“flying”]
Or does it even make a difference? The second is easier if I want to use a variable for reference (var[state]), but I’m wondering impacts performance and by how much. Thanks!