Godot Version
Godot 4.6.1
Question
I get an errors like this:
1.Used space character for indentation instead of tab as used before in the file.
2.Unexpected “Indent” in class body.
3.Expected indented block after function declaration.
4.Function “_physics_process” has the same name as a previously declared function.
5.Expected end of file.
@onready var spear_grab_area: Area2D = $SpearGrabArea
var grabbed_spear: Node = null
var is_climbing: bool = false
func _physics_process(delta):
handle_spear_interaction()
if is_climbing and grabbed_spear != null:
handle_climbing()
else:
normal_movement(delta)
the code is very messed up,you have to clean it.
extends node_goes_here
@onready var spear_grab_area: Area2D = $SpearGrabArea
var grabbed_spear: Node = null
var is_climbing: bool = false
func _physics_process(delta):
handle_spear_interaction()
if is_climbing and grabbed_spear != null:
handle_climbing()
else:
normal_movement(delta)
It sounds like you copied code from an LLM that used spaces instead of tabs. It also sounds like you have no idea what your code does. Based on the errors, I can also tell that you did not show us the entire file.
It might help if you told us what you were trying to accomplish here.
2 Likes
dudee,change the node_goes_here to whatever node type the script is attached to and then save the file
@Darty293 save that file(press Ctrl + S) it will auto-format the code
in general, I would like to make a so-called “bayonet”, if you throw it with the C button into the wall, it will get stuck in it and the character can climb it.
but I don’t understand programming at all.
You need to learn how to program. Otherwise, us solving this problem isn’t going to get you very far. And a LLM is only useful if you already know how to program. Otherwise it’s a random word generator leading the blind.
I suggest you follow some tutorials and learn. Start here: Your first 2D game — Godot Engine (stable) documentation in English At the end you will have a fully working game, and an understanding of how the Godot editor works.
Then look up some YouTube tutorials on how to throw objects in a 2D game.
3 Likes