func check_if_can_wallrun(delta: float):
var camera_tween = create_tween()
var normal_camera_orientation = Vector3(0,0,0)
var running_on_right_wall_camera_orientation = Vector3(0, 0, 15)
var running_on_left_wall_camera_orientation = Vector3(0,0,-15)
if not can_wall_run:
# Reset gravity and camera properties when not wall running
gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
camera.fov = lerp(camera.fov, normal_fov, fov_transition_speed * delta)
# Handle wall-running
if can_wall_run:
if wall_run_right.is_colliding() and not is_on_floor():
gravity *= 0.5 # Reduce gravity
camera.fov = lerp(camera.fov, wall_run_fov, fov_transition_speed * delta)
camera_tween.tween_property(camera, "rotation_degrees", running_on_right_wall_camera_orientation, 0.3)
if Input.is_action_just_pressed("Jump") and jumped_from_left_wall:
jumped_from_right_wall = true
jumped_from_left_wall = false
velocity.y = wall_run_jump_velocity # Standard jump velocity
if true:
camera_tween.tween_property(camera, "rotation_degrees", normal_camera_orientation, .5)
elif wall_run_left.is_colliding() and not is_on_floor():
camera_tween.tween_property(camera, "rotation_degrees", running_on_left_wall_camera_orientation, 0.3)
gravity *= 0.5 # Reduce gravity
camera.fov = lerp(camera.fov, wall_run_fov, fov_transition_speed * delta)
if Input.is_action_just_pressed("Jump") and jumped_from_right_wall:
jumped_from_left_wall = true
jumped_from_right_wall = false
velocity.y = wall_run_jump_velocity # Standard jump velocity
# Reset state when not wall-running
else:
if wall_run_left.is_colliding() or wall_run_right.is_colliding() == false:
print("This is running all the time, I need to find a way")
camera_tween.tween_property(camera, "rotation_degrees", normal_camera_orientation, .3)
camera.fov = lerp(camera.fov, normal_fov, fov_transition_speed * delta)
gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
if is_on_floor():
jumped_from_left_wall = true
jumped_from_right_wall = true
camera_tween.tween_property(camera, "rotation_degrees", normal_camera_orientation, .3)
I understand that the line:
if wall_run_left.is_colliding() or wall_run_right.is_colliding() == false:
print("This is running all the time, I need to find a way")
camera_tween.tween_property(camera, "rotation_degrees", normal_camera_orientation, .3)
camera.fov = lerp(camera.fov, normal_fov, fov_transition_speed * delta)
gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
Is running every second checking to see if they are not colliding. So when they aren’t colliding it still uses the tween which is why you can only look left and right and not up and down.
My question is does anyone know how to fix this problem with some code. I do ask that you should be the adjusted code please. (Godot 4.)
If you need any other information the code can be found at: https://github.com/OriginallyRetro/Godot-Movement-Script