Yeetis
1
Godot Version
4.3
Question
`Idk if Iam dumb are not but on line 3 it says Expected statement, found “Indent” instead. idk what to do
func _physics_process(delta):
if not on :floor()
velocity -= gravity * delta
var input_dir = Input.get_vector(“Left”, “Right”, “Forward”, “Back”)
var direction = (transfrom.basis * Vecter3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_side()`
Well, check all your tabs and spaces in code. There’re several options:
func _physics_process(delta: float) -> void:
print("Hi")
print("Hi x2") # unexpected indentation - extra space
func _physics_process(delta: float) -> void:
print("Hi")
if condition:
print("something else") # expected an indent block - no tab after if statement
Solve 1: Just remove extra spaces
func _physics_process(delta: float) -> void:
print("Hi")
print("Hi x2") # all is ok
Solve 2: Add tab
func _physics_process(delta: float) -> void:
print("Hi")
if condition:
print("something else") # all is ok
U put the “:” in the wrong place, should be after floor()
if not on floor():
Your code looks like a controller from a CharacterBody3D, if that’s the case the correct function is is_on_floor()
if not is_on_floor():
I recommend you study more the basics of programming and syntax before do any project.
1 Like