Godot Version
4.4.1.stable.steam
Question
My FPS camera script (that I got from LegionGames) was working before, but now I can’t move the camera, I don’t know if any of the other changes that I did on the game affected the script, and I didn’t even really touch the script itself at all
Here’s the code of the player script:
extends CharacterBody3D
@export var WALK_SPEED = 6.0
@export var speed = WALK_SPEED
@export var SPRINT_SPEED = 8.0
@export var JUMP_VELOCITY = 4.5
@export var SENSITIVITY = 0.001
#bobbing variables (not used)
const BOB_FREQ = 2.0
const BOB_AMP = 0.08
var t_bob = 0.0
@export var gravity = 9.8
@onready var head = $Head
@onready var camera = $Head/Camera3D
@onready var footstep = $PlayerAudio/Footstep
@onready var headbob: AnimationPlayer = $headbob
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _unhandled_input(event):
if event is InputEventMouseMotion:
head.rotate_y(-event.relative.x * SENSITIVITY)
camera.rotate_x(-event.relative.y * SENSITIVITY)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-40), deg_to_rad(60))
func _play_footstep_audio():
footstep.pitch_scale = randf_range(.95, 1.05)
if is_on_floor():
footstep.play()
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
#Handle Sprint
if Input.is_action_pressed("sprint"):
speed = SPRINT_SPEED
else:
speed = WALK_SPEED
var input_dir = Input.get_vector("right", "left", "back", "forward")
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if is_on_floor():
if direction:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
headbob.play("headbob_walk")
else:
velocity.x = lerp(velocity.x, direction.x * speed, delta * 7.0)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 7.0)
headbob.pause()
else:
velocity.x = lerp(velocity.x, direction.x * speed, delta * 3.0)
velocity.z = lerp(velocity.z, direction.z * speed, delta * 3.0)
headbob.pause()
#Headbob
#t_bob += delta * velocity.length() * float(is_on_floor())
#camera.transform.origin = _headbob(t_bob)
move_and_slide()
#func _headbob(time) -> Vector3:
#var pos = Vector3.ZERO
#pos.y = sin(time * BOB_FREQ) * BOB_AMP
#pos.x = cos(time * BOB_FREQ/2) * BOB_AMP
#return pos
Here’s a video of it happening:

