r/godot • u/ShiftyThatOneWriter • 11h ago
help (solved) Programming issue- Please help
I'm learning Godot to make a platformer game, but this error popped up while trying to make player movement. (this is using a 2d animated sprite)
I looked everywhere online I could and tried even getting rid of it, but the error just moved to another line instead. What do I do to fix this?
Tried:
Passing, Removing the line, Checking Commas and Parenthesis
EDIT: THANK YOU SO MUCH!!!!! I indented everything, and it fixed it. it's hard to believe i nearly had a crashout and all i needed to do was indent T-T. I am eternally grateful and bow down to your wise experience
18
u/ExpressionWorried300 Godot Student 11h ago edited 11h ago
I think you meant to put this inside of
_processor_physics_process. If statements don't work outside of functionsEdit: I can see you already tried to put
_physics_process, so this is an indentation problem. Indent everything belowfunc _physics_process(delta):so it's inside the function, everything should be indented or GDScript will assume it isnt part of the function6
u/ReallyBigSchu Godot Regular 11h ago
that statement (and several others) are not inside any functions.
5
u/-Not_a_Lizard- 11h ago
All your logic is outside the physics process function. Press Tab to indent the line.
The reason the error just jumps to another line is because it all needs to be inside the function.
2
u/FancyWrong 11h ago
You need to put this into the _process function. It should be available in a newly created script by default. You can't just put this in the top level of the script, conditions need to be in functions. If you check something once at the point the node enters the scene tree for the first time, you do it in the _ready function. If you check something every frame, you put it in the _process function or the _physics_process function if it needs to run every physics frame (might be a good idea here)
2
u/PichaelJackson 11h ago
The text underneath 'func _physics_process():' needs to be indented in order for the text parser to know that the text is contained inside that function, right now it thinks that function is empty because the lines below it are on the same indentation. GDScript is very indent dependent rather than using semicolons or brackets (for the most part, there are exceptions like setting arrays and enums and such).
2
u/Ok_Spread_2062 11h ago
You’re not indenting your code right.
No indent is class body; this is where you would do global variables and functions that is it.
Second tab is code that belongs to a function;
The third and such-forth indents are for If; For; conditional/looped code so code you’d put in a loop or if statement.
2
u/Squid_Roblox 11h ago
instead of js being in the main class have it in a 'func' maybe 'func proccess(delta):'
func is like 'def' in python the if statements arent really supposed to be in the class body but in a def function
1
u/ezekieljackson90 7h ago
Indent the if statement.
I've been trying to learn godot in my very limited free time (1-2 total hours a week). I'm so glad that I was able to figure that out. It feels like I'm making progress.