0 votes

So i assigned a variable,

var movedir = Vector2(0,0)

then when i did this

movedir.x = -int(left) + int(right)
movedir.y = -int(up down) + int()

i get this error:
Unexpected token: Identifier: movedir
(by the way i had assigned left, right, up and down)

in Engine by (12 points)

1 Answer

0 votes

You probably tried to do this outside a function. Show the rest of your script.

by (20,677 points)
extends KinematicBody2D

var movespeed = 300 

var movedir = Vector2(0,0)

func controls_loop():
    var left = Input.is_action_just_pressed("ui_left")
    var right = Input.is_action_just_pressed("ui_right")
    var up = Input.is_action_just_pressed("ui_up")
    var down = Input.is_action_just_pressed("ui_down")


movedir.x = -int(left) + int(right)
movedir.y = -int(up) + int(down)

i didnt continue because of this error

Those last two lines must be indented so that they're part of the controls_loop() function.

thanks, by the way, do you have a youtube sries for godot, because i watched your for python.

Yes, there are many Godot videos on my channel.

ok thanks, i will be sure to watch

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.