I can't try my game by a error with the "cons up Vector2(0,-1)

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

Good night
I am programming a 2d video game, when I am programming the player movement script, I get an error that says “error(7,10): Constants must be assigned immediately.” and I don’t know how to solve it, here I leave an image

Thanks for any help you can give me.

enter image description here

enter image description here

enter image description here

:bust_in_silhouette: Reply From: jgodfrey

A few things here. This issue is that your code is missing an = sign. So, instead of:

const up Vector2(0,-1)

You want this:

const up = Vector2(0, -1)

But, are you aware that the Vector2 class already has a set of constants avaiable, and this is one of them. You can access the built-in UP vector via:


See the full list of available constants here.

Oh thank you very much, I already solved that problem but I got this other one :frowning:

enter image description here

AbdielDev | 2023-05-15 02:25

Your images aren’t working in the forum (I can get the URL by editing your post). Rather that posting images of code, you’re better off posting the code itself (formatted for the forum) as well as the complete error message(s).

In this case, you have a variable (motion) that hasn’t been declared (as the error states). By the look of the surrounding code, I assume it’s a Vector2 and should be declared as a script-level variable. So, somewhere near the top - outside of any function, add this:

var motion: Vector2

jgodfrey | 2023-05-15 02:40

Already is running very well

Thank you so very much

AbdielDev | 2023-05-15 02:49