fix: correct axis direction, air accel, and jump/dash input handling

This commit is contained in:
2026-06-03 17:35:28 -04:00
parent 365264e819
commit dc2cb8ca26
4 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -40,7 +40,7 @@ func _build_input_map() -> void:
"jump": [KEY_SPACE], "jump": [KEY_SPACE],
"sprint": [KEY_SHIFT], "sprint": [KEY_SHIFT],
"crouch": [KEY_CTRL], "crouch": [KEY_CTRL],
"dash": [KEY_SHIFT], "dash": [KEY_LEFT_SHIFT],
"fire": [MOUSE_BUTTON_RIGHT, KEY_F], "fire": [MOUSE_BUTTON_RIGHT, KEY_F],
"fire_alt": [MOUSE_BUTTON_LEFT], "fire_alt": [MOUSE_BUTTON_LEFT],
"reload": [KEY_R], "reload": [KEY_R],
@@ -94,7 +94,7 @@ func _build_lighting() -> void:
func _build_player() -> void: func _build_player() -> void:
var player := CharacterBody3D.new() var player := CharacterBody3D.new()
player.name = "Player" player.name = "Player"
player.position = Vector3(0, 1.4, 8) player.position = Vector3(0, 1.7, 8)
add_child(player) add_child(player)
var shape := CollisionShape3D.new() var shape := CollisionShape3D.new()
shape.shape = CapsuleShape3D.new() shape.shape = CapsuleShape3D.new()
+2 -2
View File
@@ -50,11 +50,11 @@ func _process(_delta: float) -> void:
var sm := _ensure_machine() var sm := _ensure_machine()
if not sm: if not sm:
return return
sm.input_jump_just_pressed = Input.is_action_just_pressed("jump") and not sm.input_jump_pressed sm.input_jump_just_pressed = Input.is_action_just_pressed("jump")
sm.input_jump_pressed = Input.is_action_pressed("jump") sm.input_jump_pressed = Input.is_action_pressed("jump")
sm.input_sprint = Input.is_action_pressed("sprint") sm.input_sprint = Input.is_action_pressed("sprint")
sm.input_crouch = Input.is_action_pressed("crouch") sm.input_crouch = Input.is_action_pressed("crouch")
sm.input_dash = Input.is_action_just_pressed("dash") and not sm.input_dash sm.input_dash = Input.is_action_just_pressed("dash")
sm.input_dir = Input.get_vector("move_left", "move_right", "move_forward", "move_back") sm.input_dir = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
# DEBUG: emit every frame so we can see whether inputs reach the controller. # DEBUG: emit every frame so we can see whether inputs reach the controller.
+2 -2
View File
@@ -22,7 +22,7 @@ func update(delta: float) -> void:
# Input direction # Input direction
var input_v := machine.input_dir var input_v := machine.input_dir
var wish_dir := Vector3(input_v.x, 0.0, -input_v.y) var wish_dir := Vector3(input_v.x, 0.0, input_v.y)
if wish_dir.length_squared() > 1.0: if wish_dir.length_squared() > 1.0:
wish_dir = wish_dir.normalized() wish_dir = wish_dir.normalized()
@@ -31,7 +31,7 @@ func update(delta: float) -> void:
var hvel := Vector3(vel.x, 0.0, vel.z) var hvel := Vector3(vel.x, 0.0, vel.z)
var target_vel := wish_dir * effective_speed * params.air_control var target_vel := wish_dir * effective_speed * params.air_control
hvel = hvel.lerp(Vector3(hvel.x + target_vel.x, 0.0, hvel.z + target_vel.z), 1.0 - exp(-params.air_acceleration * delta)) hvel = hvel.lerp(target_vel, 1.0 - exp(-params.air_acceleration * delta))
vel.x = hvel.x vel.x = hvel.x
vel.z = hvel.z vel.z = hvel.z
+1 -1
View File
@@ -19,7 +19,7 @@ func update(delta: float) -> void:
# Input direction # Input direction
var input_v := machine.input_dir var input_v := machine.input_dir
var wish_dir := Vector3(input_v.x, 0.0, -input_v.y) var wish_dir := Vector3(input_v.x, 0.0, input_v.y)
if wish_dir.length_squared() > 1.0: if wish_dir.length_squared() > 1.0:
wish_dir = wish_dir.normalized() wish_dir = wish_dir.normalized()