|Attention||Topic was automatically imported from the old Question2Answer platform.|
Hi, so I am trying to accomplish a selection from whenever you press an arrow key, it will find the nearest selectable unit on the direction of the pressed key and select that unit.
For example, currently I am at the center position, so whenever I press the UP key, the top position will be selected. But if I press the UP key again, the selection will cycle back to the bottom position. And pressing the UP key again will bring the selection back to the center.
I tried using two-dimensional Array and load each position into the Array, and whenever a key is pressed it will either subtract or addition depending on the direction to make the selection, although this will only work if the position are not moving.
var enemy_party = [[$Enemy1, $Enemy2, $Enemy3], [$Enemy4, $Enemy5, $Enemy6], [$Enemy7, $Enemy8, $Enemy9]
I am planning to make the enemies move so the position will change, how should I approach this?