Invalid getindex in dictionary

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By torohaifisch

Hello everyone i am using this dictionary

var enemy_dict= {

in this function

func spawn_enemy(enemy):

ene= load(enemy_dict[enemy])
var enemigo=ene.instance()

so spawn enemy gets its value from the x component of a vector2 lets say it is setup
(i am setting up the array using the inspector) as in this image Imgur: The magic of the Internet

the problem is when i do spawn_enemy(vect.x) it throws this error:
Invalid get index ‘1’ (on base dictionary)

can anyone explain me what am i doing wrong?

:bust_in_silhouette: Reply From: Zylann

Vector2 contains float numbers, but your array is created with int indexes. Maybe the key cannot be found because of type mismatch or precision error?
You can also check if your dictionary contains what you expect in the debugger when the error happens.