CharacterBody3D cannot move at all despite assigned inputs

Godot Version

4.5.1

Question

Hi! I've been having various troubles with my CharacterBody3D in relation to movement and I've been searching for hours trying to find a fix to no avail. Previously, I was using a Node 3D with a camera attached, and had an odd issue where my character could only move if I rapidly flicked the camera left and right, even falling would pause if i didnt move the camera. I completely removed that camera from the scene and the script and made a new SpringArm3D parented camera with a new script, and *now* the player character cannot move at all. Attached are the only 2 scripts in the scene. I have tried enabling physics interpolation, changing tick rate, changing collision shape, but no luck so far. tysm for any help!

player.gd for the player themself

extends CharacterBody3D

@onready var animation_player: AnimationPlayer = $visuals/mixamo_base/AnimationPlayer
@onready var visuals: Node3D = $visuals


var SPEED = 3.0
const JUMP_VELOCITY = 4.5

var walking_speed = 3.0
var running_speed = 5.0

@export var sens_horizontal = 0.4
@export var sens_vertical = 0.4

func _physics_process(delta: float) -> void:
	
	if Input.is_action_pressed("run"):
		SPEED = running_speed
	else:
		SPEED = walking_speed
		
	# Add the gravity.
	if not is_on_floor():
		velocity += get_gravity() * delta

func _ready():
	Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

	# Handle jump.
	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		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("left", "right", "forward", "backward")
	var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
	if direction:
		if animation_player.current_animation != "walking":
			animation_player.play("walking")
			
		visuals.look_at(position + direction)
		
		velocity.x = direction.x * SPEED
		velocity.z = direction.z * SPEED

	else:
		if animation_player.current_animation != "idle":
			animation_player.play("idle")
		velocity.x = move_toward(velocity.x, 0, SPEED)
		velocity.z = move_toward(velocity.z, 0, SPEED)

	move_and_slide()

and camera_spring_arm.gd for the camera

extends SpringArm3D

@export var mouse_sensibility: float = 0.005


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
	
func _unhandled_input(event : InputEvent) -> void:
		if event is InputEventMouseMotion:
			rotation.y -= event.relative.x * mouse_sensibility
			
			rotation.x -= event.relative.y * mouse_sensibility

The _ready function only runs at the start, so your inputs only check at the very beginning, you probably accidentally inserted the _ready in between your _physics_process code rather than giving _ready it’s own space.

1 Like

omg, go figure the issue is something that small!! Thankyou so much for the fast reply, I was looking all around and over the issue and not noticing it right infront of me and I can’t imagine how many people have done the same thing haha. it’s resolved now!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.