return jumping to _physics_process

This commit is contained in:
Teatov 2025-02-13 23:35:49 +10:00
parent c57c724f0a
commit bb3b75929a

View File

@ -79,6 +79,8 @@ func _physics_process(delta: float) -> void:
_lateral_movement(delta)
_vertical_movement(delta)
_jumping()
move_and_slide()
@ -92,9 +94,6 @@ func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
_handle_mouse_rotating(event as InputEventMouseMotion)
if event.is_action_pressed("jump"):
_jump()
if event.is_action_pressed("crouch"):
_crouch = true
if event.is_action_released("crouch"):
@ -202,6 +201,15 @@ func _vertical_movement(delta: float) -> void:
velocity.y = 0
func _jumping() -> void:
if (
Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED
and Input.is_action_just_pressed("jump")
and is_on_floor()
):
velocity.y = JUMP_FORCE
func _handle_mouse_rotating(event: InputEventMouseMotion) -> void:
var sensitivity := deg_to_rad(Settings.mouse_sensitivity)
@ -223,11 +231,6 @@ func _handle_mouse_rotating(event: InputEventMouseMotion) -> void:
_camera.rotation.x = clamp(_camera.rotation.x, -PI / 2, PI / 2)
func _jump() -> void:
if is_on_floor():
velocity.y = JUMP_FORCE
func _on_networker_player_registered(peer_id: int, player_info: Dictionary) -> void:
if peer_id != _peer_id:
return