system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
S JaK |
Here is my code and I don’t have any idea what is wrong with if:
extends Node2D
var left_pos = get_node("guy").get_pos()
if Input.is_action_pressed("move_right"):
left_pos.y += 10
func _ready():
pass
system
2
|
|
|
|
Reply From: |
volzhs |
you can’t write code outside of function, except define variable.
you need to move it inside of function.
for example
extends Node2D
var left_pos = get_node("guy").get_pos()
func _ready():
pass
func _process():
if Input.is_action_pressed("move_right"):
left_pos.y += 10
I suggest you to read document for GDscript.
Thanks a lot! That solved my problem.