What does "Standalone lambdas cannot be accessed. Consider assigning it to a variable"

Godot Version

Godot version 4.2.1

Question

I’m extremely new to godot, and I’m trying to make 3d player movement using a tutorial on docs.godotengine.org, and when I use a piece of code, I get the error message seen above. Can anyone help me know what it means

Line of code that makes the message display:

func _physics_process (_delta):

The page I’m using as help:

Will give more information if asked

Not sure if you found a solution yet plus you didn’t give much info but its likely a problem with indentation.
If you copy and pasted it directly from the docs it might have pasted into the engine without proper spacing. Try retyping instead (if you did copy and paste) and see if the error still persists.
Otherwise maybe remove the underscore by delta (instead of _delta use delta).

2 Likes

retyped it and removed the underscore, but the error still persisted. Here’s the lines of code that are apart of the line that’s in the question (if that’s the correct term)

	if direction != Vector3.ZERO:
		target_velocity.x = direction.x * speed
		target_velocity.z = direction.z * speed
	if not is_on_floor():
		target_velocity.y = target_velocity.y - (fall_acceleration * delta)
	velocity = target_velocity
	move_and_slide()

Can you show the entire script?

1 Like

Solution probably has been found by now but will post the solution in case any else requires it.

This is most probably to do with the fact that the code has been tabbed across at least one space in the declaration of the function, this is often very difficult to spot!

	func _input(event:InputEvent) -> void:	
		if event is InputEventMouseMotion:
			mouse_motion = - event.relative * 0.001 #mouse sensitivity

Instead of :

func _input(event:InputEvent) -> void:	
	if event is InputEventMouseMotion:
		mouse_motion = - event.relative * 0.001

(sorry this dialog will not show it very well.)

Just need to hightlight the text and shift-tab

Hope this helps.