Godot Version
v4
Question
i am making a wall run script in my player controls bases of playable workshop and devdrache although i ran into an issue with having to turn standalone lambdas to a variable very new to game dev as it is and i need someone to help with lines 51, 71 and 107
extends CharacterBody3D
@onready var anim_player: AnimationPlayer = $mesh/AnimationPlayer
@onready var animation_tree: AnimationTree = $AnimationTree
var last_lean := 0.0
@export var speed := 5.0
const JUMP_VELOCITY = 6.5
@onready var mesh: Node3D = $mesh
@onready var camera: Node3D = $CameraRig/Camera3D
@onready var ray_cast_right: RayCast3D = $RayCastRight
@onready var ray_cast_left: RayCast3D = $RayCastLeft
var remaining_jumps := 2
func _physics_process(delta: float) -> void:
#Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
remaining_jumps = 2
# Handle jump.
if Input.is_action_just_pressed("move_jump") and remaining_jumps > 0:
remaining_jumps -= 1
velocity.y = JUMP_VELOCITY
#
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
var direction := (camera.global_basis * Vector3(input_dir.x, 0, input_dir.y))
direction = Vector3(direction.x, 0, direction.z).normalized() * input_dir.length()
if not is_on_floor() and _wall_on_slide() and Input.is_action_pressed("dash"):
_wall_run(direction)
else:
_normal_run(direction)
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_slide()
turn_to(direction)
func _wall_on_slide():
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
func _wall_run(direction):
velocity.y = 0
var wallNormal
var collisionDistance
var distanceOffset = 0.2
if ray_cast_right.is_colliding():
wallNormal = ray_cast_right.get_collision_normal()
collisionDistance = ray_cast_right.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= -45
elif ray_cast_left.is_colliding():
wallNormal = ray_cast_left.get_collision_normal()
collisionDistance = ray_cast_left.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= 45
mesh.position = collisionDistance * -wallNormal
func _normal_run(direction):
mesh.rotation_degrees.z= 0
mesh.position = Vector3.ZERO
if direction:
var targetAngle = atan2(direction.x,direction.z) - rotation.y
mesh.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
ray_cast_right.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
ray_cast_left.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
var current_speed := velocity.length()
const RUN_SPEED := 4
const BLEND_SPEED := 0.2
if not is_on_floor():
animation_tree.set("parameters/movement/transition_request", "fall")
elif current_speed > RUN_SPEED:
animation_tree.set("parameters/movement/transition_request", "run")
var lean := direction.dot(global_basis.x)
last_lean = lerpf(last_lean, lean, 0.3)
animation_tree.set("parameters/run_lean/add_amount", last_lean)
elif current_speed > 0.0:
animation_tree.set("parameters/movement/transition_request", "walk")
var walk_speed := lerpf(0.5, 1.75, current_speed/RUN_SPEED)
animation_tree.set("parameters/TimeScale/scale", walk_speed)
else:
animation_tree.set("parameters/movement/transition_request", "idle")
func turn_to(direction: Vector3)-> void:
if direction:
var yaw:= atan2(-direction.x, -direction.z)
yaw = lerp_angle(rotation.y, yaw, .25)
rotation.y = yaw
Unindent the _wall_run function.
1 Like
Try what @paintsimmon said.
And NGL, I am not counting line numbers. Add some comments in on the offending lines if you’re still having an issue.
It creates more errors mostly with about static type
You will have to post your updated code.
how do i do that im new to the forum
extends CharacterBody3D
@onready var anim_player: AnimationPlayer = $mesh/AnimationPlayer
@onready var animation_tree: AnimationTree = $AnimationTree
var last_lean := 0.0
@export var speed := 5.0
const JUMP_VELOCITY = 6.5
@onready var mesh: Node3D = $mesh
@onready var camera: Node3D = $CameraRig/Camera3D
@onready var ray_cast_right: RayCast3D = $RayCastRight
@onready var ray_cast_left: RayCast3D = $RayCastLeft
var remaining_jumps := 2
func _physics_process(delta: float) -> void:
#Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
remaining_jumps = 2
# Handle jump.
if Input.is_action_just_pressed("move_jump") and remaining_jumps > 0:
remaining_jumps -= 1
velocity.y = JUMP_VELOCITY
#
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
var direction := (camera.global_basis * Vector3(input_dir.x, 0, input_dir.y))
direction = Vector3(direction.x, 0, direction.z).normalized() * input_dir.length()
if not is_on_floor() and _wall_on_slide() and Input.is_action_pressed("dash"):
_wall_run(direction)
else:
_normal_run(direction)
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_slide()
turn_to(direction)
func _wall_on_slide():
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
func _wall_run(direction):#error
velocity.y = 0
var wallNormal
var collisionDistance
var distanceOffset = 0.2
if ray_cast_right.is_colliding():
wallNormal = ray_cast_right.get_collision_normal()
collisionDistance = ray_cast_right.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= -45
elif ray_cast_left.is_colliding():
wallNormal = ray_cast_left.get_collision_normal()
collisionDistance = ray_cast_left.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= 45
mesh.position = collisionDistance * -wallNormal
func _normal_run(direction):#error
mesh.rotation_degrees.z= 0
mesh.position = Vector3.ZERO
if direction:
var targetAngle = atan2(direction.x,direction.z) - rotation.y
mesh.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
ray_cast_right.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
ray_cast_left.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
var current_speed := velocity.length()
const RUN_SPEED := 4
const BLEND_SPEED := 0.2
if not is_on_floor():
animation_tree.set("parameters/movement/transition_request", "fall")
elif current_speed > RUN_SPEED:
animation_tree.set("parameters/movement/transition_request", "run")
var lean := direction.dot(global_basis.x)
last_lean = lerpf(last_lean, lean, 0.3)
animation_tree.set("parameters/run_lean/add_amount", last_lean)
elif current_speed > 0.0:
animation_tree.set("parameters/movement/transition_request", "walk")
var walk_speed := lerpf(0.5, 1.75, current_speed/RUN_SPEED)
animation_tree.set("parameters/TimeScale/scale", walk_speed)
else:
animation_tree.set("parameters/movement/transition_request", "idle")
func turn_to(direction: Vector3)-> void:#error
if direction:
var yaw:= atan2(-direction.x, -direction.z)
yaw = lerp_angle(rotation.y, yaw, .25)
rotation.y = yaw
your func _wall_run remains indented. Your script should look like this
extends CharacterBody3D
@onready var anim_player: AnimationPlayer = $mesh/AnimationPlayer
@onready var animation_tree: AnimationTree = $AnimationTree
var last_lean := 0.0
@export var speed := 5.0
const JUMP_VELOCITY = 6.5
@onready var mesh: Node3D = $mesh
@onready var camera: Node3D = $CameraRig/Camera3D
@onready var ray_cast_right: RayCast3D = $RayCastRight
@onready var ray_cast_left: RayCast3D = $RayCastLeft
var remaining_jumps := 2
func _physics_process(delta: float) -> void:
#Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
remaining_jumps = 2
# Handle jump.
if Input.is_action_just_pressed("move_jump") and remaining_jumps > 0:
remaining_jumps -= 1
velocity.y = JUMP_VELOCITY
#
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
var direction := (camera.global_basis * Vector3(input_dir.x, 0, input_dir.y))
direction = Vector3(direction.x, 0, direction.z).normalized() * input_dir.length()
if not is_on_floor() and _wall_on_slide() and Input.is_action_pressed("dash"):
_wall_run(direction)
else:
_normal_run(direction)
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_slide()
turn_to(direction)
func _wall_on_slide():
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
##### Un-indent start #####
func _wall_run(direction):#error
velocity.y = 0
var wallNormal
var collisionDistance
var distanceOffset = 0.2
if ray_cast_right.is_colliding():
wallNormal = ray_cast_right.get_collision_normal()
collisionDistance = ray_cast_right.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= -45
elif ray_cast_left.is_colliding():
wallNormal = ray_cast_left.get_collision_normal()
collisionDistance = ray_cast_left.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= 45
mesh.position = collisionDistance * -wallNormal
##### Un-indent end #####
func _normal_run(direction):#error
mesh.rotation_degrees.z= 0
mesh.position = Vector3.ZERO
if direction:
var targetAngle = atan2(direction.x,direction.z) - rotation.y
mesh.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
ray_cast_right.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
ray_cast_left.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
var current_speed := velocity.length()
const RUN_SPEED := 4
const BLEND_SPEED := 0.2
if not is_on_floor():
animation_tree.set("parameters/movement/transition_request", "fall")
elif current_speed > RUN_SPEED:
animation_tree.set("parameters/movement/transition_request", "run")
var lean := direction.dot(global_basis.x)
last_lean = lerpf(last_lean, lean, 0.3)
animation_tree.set("parameters/run_lean/add_amount", last_lean)
elif current_speed > 0.0:
animation_tree.set("parameters/movement/transition_request", "walk")
var walk_speed := lerpf(0.5, 1.75, current_speed/RUN_SPEED)
animation_tree.set("parameters/TimeScale/scale", walk_speed)
else:
animation_tree.set("parameters/movement/transition_request", "idle")
func turn_to(direction: Vector3)-> void:#error
if direction:
var yaw:= atan2(-direction.x, -direction.z)
yaw = lerp_angle(rotation.y, yaw, .25)
rotation.y = yaw
1 Like
made changes new errors are commented
extends CharacterBody3D
@onready var anim_player: AnimationPlayer = $mesh/AnimationPlayer
@onready var animation_tree: AnimationTree = $AnimationTree
var last_lean := 0.0
@export var speed := 5.0
const JUMP_VELOCITY = 6.5
@onready var mesh: Node3D = $mesh
@onready var camera: Node3D = $CameraRig/Camera3D
@onready var ray_cast_right: RayCast3D = $RayCastRight
@onready var ray_cast_left: RayCast3D = $RayCastLeft
var remaining_jumps := 2
func _physics_process(delta: float) -> void:
#Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
remaining_jumps = 2
# Handle jump.
if Input.is_action_just_pressed("move_jump") and remaining_jumps > 0:
remaining_jumps -= 1
velocity.y = JUMP_VELOCITY
#
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
var direction := (camera.global_basis * Vector3(input_dir.x, 0, input_dir.y))
direction = Vector3(direction.x, 0, direction.z).normalized() * input_dir.length()
if not is_on_floor() and _wall_on_slide() and Input.is_action_pressed("dash"):
_wall_run(direction)
else:
_normal_run(direction)
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_slide()
turn_to(direction)
func _wall_on_slide():#unction "_wall_on_slide()" has no static return type. (Warning treated as error.)
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
func _wall_run(direction):#Parameter "direction" has no static type. (Warning treated as error.)Function "_wall_run()" has no static return type. (Warning treated as error.)
velocity.y = 0
var wallNormal#:Variable "wallNormal" has no static type. (Warning treated as error.)
var collisionDistance#Variable "collisionDistance" has no static type. (Warning treated as error.)
var distanceOffset = 0.2#Variable "distanceOffset" has no static type. (Warning treated as error.)
if ray_cast_right.is_colliding():
wallNormal = ray_cast_right.get_collision_normal()
collisionDistance = ray_cast_right.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= -45
elif ray_cast_left.is_colliding():
wallNormal = ray_cast_left.get_collision_normal()
collisionDistance = ray_cast_left.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= 45
mesh.position = collisionDistance * -wallNormal
func _normal_run(direction):#Function "_normal_run()" has no static return type. (Warning treated as error.)Parameter "direction" has no static type. (Warning treated as error.)
mesh.rotation_degrees.z= 0
mesh.position = Vector3.ZERO
if direction:
var targetAngle = atan2(direction.x,direction.z) - rotation.y#Variable "targetAngle" has no static type. (Warning treated as error.)
mesh.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
ray_cast_right.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
ray_cast_left.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
var current_speed := velocity.length()
const RUN_SPEED := 4
const BLEND_SPEED := 0.2
if not is_on_floor():
animation_tree.set("parameters/movement/transition_request", "fall")
elif current_speed > RUN_SPEED:
animation_tree.set("parameters/movement/transition_request", "run")
var lean := direction.dot(global_basis.x)#Cannot infer the type of "lean" variable because the value doesn't have a set type.
last_lean = lerpf(last_lean, lean, 0.3)
animation_tree.set("parameters/run_lean/add_amount", last_lean)
elif current_speed > 0.0:
animation_tree.set("parameters/movement/transition_request", "walk")
var walk_speed := lerpf(0.5, 1.75, current_speed/RUN_SPEED)
animation_tree.set("parameters/TimeScale/scale", walk_speed)
else:
animation_tree.set("parameters/movement/transition_request", "idle")
func turn_to(direction: Vector3)-> void:#error
if direction:
var yaw:= atan2(-direction.x, -direction.z)
yaw = lerp_angle(rotation.y, yaw, .25)
rotation.y = yaw
You have warnings treated as errors turned on. Don’t do that if you aren’t sure what you are doing.
“thing” has no static type
Means you have not declared a type for the variable or function, for example your _wall_on_slide returns a true/false value so it should return bool
func _wall_on_slide() -> bool:
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
Variables are typed with colon :
var wallNormal: Vector3
You can insert this before assignment too =
var distanceOffset: float = 0.2
In this guide, you will learn: how to use static typing in GDScript;, that static types can help you avoid bugs;, that static typing improves your experience with the editor.. Where and how you use...
2 Likes
Tolu_Od
February 7, 2026, 8:17am
11
thanks for the tip but still ran into the lambda issue
extends CharacterBody3D
@onready var anim_player: AnimationPlayer = $mesh/AnimationPlayer
@onready var animation_tree: AnimationTree = $AnimationTree
var last_lean := 0.0
@export var speed := 5.0
const JUMP_VELOCITY = 6.5
@onready var mesh: Node3D = $mesh
@onready var camera: Node3D = $CameraRig/Camera3D
@onready var ray_cast_right: RayCast3D = $RayCastRight
@onready var ray_cast_left: RayCast3D = $RayCastLeft
var remaining_jumps := 2
func _physics_process(delta: float) -> void:
#Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
remaining_jumps = 2
# Handle jump.
if Input.is_action_just_pressed("move_jump") and remaining_jumps > 0:
remaining_jumps -= 1
velocity.y = JUMP_VELOCITY
#
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
var direction := (camera.global_basis * Vector3(input_dir.x, 0, input_dir.y))
direction = Vector3(direction.x, 0, direction.z).normalized() * input_dir.length()
if not is_on_floor() and _wall_on_slide() and Input.is_action_pressed("dash"):
_wall_run(direction)
else:
_normal_run(direction)
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_slide()
turn_to(direction)
func _wall_on_slide() -> bool:#Standalone lambdas cannot be accessed. Consider assigning it to a variable.
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
func _wall_run(direction):#Standalone lambdas cannot be accessed. Consider assigning it to a variable.
velocity.y = 0
var wallNormal: Vector3
var collisionDistance
var distanceOffset: float = 0.2
if ray_cast_right.is_colliding():
wallNormal = ray_cast_right.get_collision_normal()
collisionDistance = ray_cast_right.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= -45
elif ray_cast_left.is_colliding():
wallNormal = ray_cast_left.get_collision_normal()
collisionDistance = ray_cast_left.get_collision_point().direction_to(global_position) - distanceOffset
mesh.rotation_degrees.z= 45
mesh.position = collisionDistance * -wallNormal
func _normal_run(direction):#Standalone lambdas cannot be accessed. Consider assigning it to a variable.
mesh.rotation_degrees.z= 0
mesh.position = Vector3.ZERO
if direction:
var targetAngle = atan2(direction.x,direction.z) - rotation.y
mesh.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
ray_cast_right.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
ray_cast_left.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
var current_speed := velocity.length()
const RUN_SPEED := 4
const BLEND_SPEED := 0.2
if not is_on_floor():
animation_tree.set("parameters/movement/transition_request", "fall")
elif current_speed > RUN_SPEED:
animation_tree.set("parameters/movement/transition_request", "run")
var lean := direction.dot(global_basis.x)
last_lean = lerpf(last_lean, lean, 0.3)
animation_tree.set("parameters/run_lean/add_amount", last_lean)
elif current_speed > 0.0:
animation_tree.set("parameters/movement/transition_request", "walk")
var walk_speed := lerpf(0.5, 1.75, current_speed/RUN_SPEED)
animation_tree.set("parameters/TimeScale/scale", walk_speed)
else:
animation_tree.set("parameters/movement/transition_request", "idle")
func turn_to(direction: Vector3)-> void:##Standalone lambdas cannot be accessed. Consider assigning it to a variable.
if direction:
var yaw:= atan2(-direction.x, -direction.z)
yaw = lerp_angle(rotation.y, yaw, .25)
rotation.y = yaw
There’s no “lambda issue”. You just didn’t indent your functions properly. There shouldn’t be any tabs before the keyword func. Indentation matters in GDScript as it defines the code blocks.
func _wall_on_slide() -> bool:#Standalone lambdas cannot be accessed. Consider assigning it to a variable.
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
Correct:
func _wall_on_slide() -> bool:
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
4 Likes
Tolu_Od
February 9, 2026, 6:57am
14
Thanks for the help
extends CharacterBody3D
@onready var anim_player: AnimationPlayer = $mesh/AnimationPlayer
@onready var animation_tree: AnimationTree = $AnimationTree
var last_lean := 0.0
@export var speed := 5.0
const JUMP_VELOCITY = 6.5
@onready var mesh: Node3D = $mesh
@onready var camera: Node3D = $CameraRig/Camera3D
@onready var ray_cast_right: RayCast3D = $RayCastRight
@onready var ray_cast_left: RayCast3D = $RayCastLeft
var remaining_jumps := 2
func _physics_process(delta: float) -> void:
#Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
else:
remaining_jumps = 2
# Handle jump.
if Input.is_action_just_pressed("move_jump") and remaining_jumps > 0:
remaining_jumps -= 1
velocity.y = JUMP_VELOCITY
#
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("move_left", "move_right", "move_forwards", "move_backwards")
var direction := (camera.global_basis * Vector3(input_dir.x, 0, input_dir.y))
direction = Vector3(direction.x, 0, direction.z).normalized() * input_dir.length()
if not is_on_floor() and _wall_on_slide() and Input.is_action_pressed("dash"):
_wall_run(direction)
else:
_normal_run(direction)
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_slide()
turn_to(direction)
func _wall_on_slide() -> bool:
return ray_cast_right.is_colliding() or ray_cast_left.is_colliding()
func _wall_run(direction):
velocity.y = 0
var wallNormal: Vector3
var collisionDistance
var distanceOffset: float = 0.2
if ray_cast_right.is_colliding():
wallNormal = ray_cast_right.get_collision_normal()
collisionDistance = ray_cast_right.get_collision_point().direction_to(global_position) - distanceOffset#Invalid operands "Vector3" and "float" for "-" operator.
mesh.rotation_degrees.z= -45
elif ray_cast_left.is_colliding():
wallNormal = ray_cast_left.get_collision_normal()
collisionDistance = ray_cast_left.get_collision_point().direction_to(global_position) - distanceOffset#Invalid operands "Vector3" and "float" for "-" operator.
mesh.rotation_degrees.z= 45
mesh.position = collisionDistance * -wallNormal
func _normal_run(direction):
mesh.rotation_degrees.z= 0
mesh.position = Vector3.ZERO
if direction:
var targetAngle = atan2(direction.x,direction.z) - rotation.y
mesh.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
ray_cast_right.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
ray_cast_left.rotation.y = lerp_angle(mesh.rotation.y, targetAngle, 0.1)
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
var current_speed := velocity.length()
const RUN_SPEED := 4
const BLEND_SPEED := 0.2
if not is_on_floor():
animation_tree.set("parameters/movement/transition_request", "fall")
elif current_speed > RUN_SPEED:
animation_tree.set("parameters/movement/transition_request", "run")
var lean := direction.dot(global_basis.x)#Cannot infer the type of "lean" variable because the value doesn't have a set type.
last_lean = lerpf(last_lean, lean, 0.3)
animation_tree.set("parameters/run_lean/add_amount", last_lean)
elif current_speed > 0.0:
animation_tree.set("parameters/movement/transition_request", "walk")
var walk_speed := lerpf(0.5, 1.75, current_speed/RUN_SPEED)
animation_tree.set("parameters/TimeScale/scale", walk_speed)
else:
animation_tree.set("parameters/movement/transition_request", "idle")
func turn_to(direction: Vector3)-> void:
if direction:
var yaw:= atan2(-direction.x, -direction.z)
yaw = lerp_angle(rotation.y, yaw, .25)
rotation.y = yaw
sancho2
February 10, 2026, 7:08pm
16
var lean := direction.dot(global_basis.x)
The dot() method of a vector returns a float. I don’t know why this can’t be inferred but try it with a defined type:
var lean :float = direction.dot(global_basis.x)
The problem could be that since direction hasn’t been given a type in that function it is a variant but that is a guess.
In my opinion type inference shouldn’t be used by people just starting out. I never use them.
It is very helpful to mark the line the error occurs on (as you did).
I also think that you should give a clue as to what the problem is in a short paragraph at the top/bottom of your post.
On my first read I didn’t see that there was still an error.
2 Likes
It cannot be inferred because the type of direction is not declared.
3 Likes
Tolu_Od
February 13, 2026, 3:08am
18
Hey, GDScripters, thanks for all your help. The wall run mechanic finally works, added a anim_tree.set to a run parameter cause it was just showing the fall anim state, and its preemo. Thanks again for your help, everyone
3 Likes