Character controller isn't moving forwards or backwards

Godot Version

Godot 4.3

Question

Hello! So, I am trying to implement a character controller into my game, and it’s being weird. The side-to-side movement works just fine, but for some reason moving back and forth is super slow to the point its unplayable. Here is my code:

func _handle_air_physics(delta) -> void:
	self.velocity.y -= gravity * delta
	self.velocity.x = wish_dir.x * speed
	self.velocity.z = wish_dir.z * speed

func _handle_ground_physics(delta) -> void:
	self.velocity.x = wish_dir.x * speed
	self.velocity.z = wish_dir.z * speed 
			
func _physics_process(delta):
	var input_dir := Input.get_vector("left", "right", "up", "down").normalized()
	wish_dir = (self.global_transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
	if is_on_floor():
		if Input.is_action_just_pressed("jump"):
			self.velocity.y = jump
		_handle_ground_physics(delta)
	else:
		_handle_air_physics(delta)
	if is_on_wall() and Input.is_action_just_pressed("jump", true):
		self.velocity.y = jump
	
	move_and_slide()

Thank you to anyone who helps me. Cheers!

What does _handle_ground_physics() look like?

1 Like

When the game is running or the code the function has? The code for _handle_ground_physics() is already in the original post.

Here is the bug in action. Apparently, the bug is different now? Now moving forward, backwards, and side to side works fine, but moving diagonal stops the character from moving (or at least stops it from moving forwards). Can anyone help?

You set the video to private, we can’t see it.

I have no idea how I never noticed this. What the heck!? Well, I fixed it and now its unlisted.

Do you mean you fixed your problem mentioned here, or do you still need help?

No I still need help, but the video that shows the problem is able to be seen by the people in the forums. It is not private anymore.

Ah, ok.
Is your code still unchanged since you posted it initially in the original post above?
And your issue is that pressing 2 actions at the same time, e.g. “up” and “right”, it won’t go diagonally?

Yes. I haven’t changed the code since uploading and the main problem is that forward and backward movement stops when you try to move diagonally, so diagonal movement is impossible. Thank you so much for trying to help me.