system
April 26, 2023, 6:16pm
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
KerbalAstronaut
extends CharacterBody2D
func _physics_process(delta):
var input_direction=Vector2(
Input.get_action_strength("player_right") - Input.get_action_strength("player_left")
Input.get_action_strength("player_down") - Input.get_action_strength("player_up")
)
print(input_direction)
It says
Line 9:Unexpected “Identifier” in class body.
system
April 26, 2023, 6:25pm
2
Reply From:
godot_dev_
You can’t just have a print
statement floating around in your code like that (your have an indentation problem). you must call print (or any function/logic statement for that matter) inside a function. Adding print
in your _physics_process
function as follows should fix the compilation error:
extends CharacterBody2D
func _physics_process(delta):
var input_direction=Vector2(
Input.get_action_strength("player_right") - Input.get_action_strength("player_left")
Input.get_action_strength("player_down") - Input.get_action_strength("player_up")
)
print(input_direction)
Also, I believe you may be missing a ,
in your Vector2
call, but I am not sure
godot_dev_ | 2023-04-26 18:25
system
April 26, 2023, 10:47pm
3
Reply From:
0
GDScript is indent based language so you gotta be careful on how you are tabbing things.
Make sure to have this enabled on your settings:
Editor Settings → Text Editor → Appearance → Draw Tabs
Make things much easier to see