Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | razor7131 |
When I tried to parse enemy data the one that involves enum, it always gives the default value here the code:
func parse_enemy_data():
var new_enemy
print("Enemy class: ", data.enemy_class) #Return 1
match data.enemy_class:
0: # Class normal
new_enemy = enemy_normal_resource.instance()
new_enemy.enemy_class = 0
1: # Class mid
new_enemy = enemy_mid_resource.instance()
new_enemy.enemy_class = 1
2: # Class high
new_enemy = enemy_high_resource.instance()
new_enemy.enemy_class = 2
_:
push_error("Invalid enemy class.")
enemy_container.add_child(new_enemy)
...
Here’s how the data structure looks like:
{"drop_item":"GOLD","enemy_class":1,"health":100,"name":"Enemy","pos_x":1052.812622,"pos_y":467.378937,"score":3}
Why this is happened? Thanks for your time.
It works however if I use if statement instead. If possible I want to use this statement instead since it was cleaner and easy to read.
razor7131 | 2020-11-04 19:39