Im getting an error and i dont know why.

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

This is the line of code im getting the error on

vector2(-1,0):

Im getting this error-
error(30,16): Invalid in pattern. Only index (A.B) is allowed

it’s hard to say what’s wrong with just 1 line of code.

did you type vector2(-1,0) not Vector2(-1,0)?
why : is added at the end of line?

volzhs | 2019-03-18 12:19

Take a look here to see if it helps you, Cannot call own functions inside a match pattern · Issue #18174 · godotengine/godot · GitHub

intrus18 | 2019-03-18 13:45

This is the full line of code,

func spritedir_loop():
match movedir:
Vector2(-1,0):
spritedir = “left”
vector2(1,0):
spritedir = “right”
vector2(0,1):
spritedir = “up”
vector(0,1):
spritedir = “down”

Sollus_PRIME | 2019-03-18 19:36