I started to make a game in godot and wanted to make a death zone where if the player enters it he automaticly gets teleportet to a certain point.
It didn´t work and it said : Error at (1, 15) Unexpected “Identifier” in class body
here is the code :
extends Area2D
Marker2D.to_global
Called when the node enters the scene tree for the first time.
func _ready() → void:
pass # Replace with function body.
Called every frame. ‘delta’ is the elapsed time since the previous frame.
func _process(delta: float) → void:
pass
func _on_body_entered(body: Node2D) → void:
if body.is_in_group(“Player”):
body.set_position($“…/Marker2D”.position_global)
“Unexpected ____ in class body” is a indentation error, which requires proper formatting to show in the forum
GDScript is white space sensitive meaning the tabs you add influence how the code runs. Including producing syntax errors if the computer cannot understand your indentation. I’m betting body.set_position($"../Marker2D".global_position) needs further indentation to be a part of the if statement above it.
Make sure to paste with three ticks ``` or a [code] block surrounding your code pastes