return jumping to _physics_process
This commit is contained in:
parent
c57c724f0a
commit
bb3b75929a
@ -79,6 +79,8 @@ func _physics_process(delta: float) -> void:
|
|||||||
_lateral_movement(delta)
|
_lateral_movement(delta)
|
||||||
_vertical_movement(delta)
|
_vertical_movement(delta)
|
||||||
|
|
||||||
|
_jumping()
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
|
||||||
@ -92,9 +94,6 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
_handle_mouse_rotating(event as InputEventMouseMotion)
|
_handle_mouse_rotating(event as InputEventMouseMotion)
|
||||||
|
|
||||||
if event.is_action_pressed("jump"):
|
|
||||||
_jump()
|
|
||||||
|
|
||||||
if event.is_action_pressed("crouch"):
|
if event.is_action_pressed("crouch"):
|
||||||
_crouch = true
|
_crouch = true
|
||||||
if event.is_action_released("crouch"):
|
if event.is_action_released("crouch"):
|
||||||
@ -202,6 +201,15 @@ func _vertical_movement(delta: float) -> void:
|
|||||||
velocity.y = 0
|
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:
|
func _handle_mouse_rotating(event: InputEventMouseMotion) -> void:
|
||||||
var sensitivity := deg_to_rad(Settings.mouse_sensitivity)
|
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)
|
_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:
|
func _on_networker_player_registered(peer_id: int, player_info: Dictionary) -> void:
|
||||||
if peer_id != _peer_id:
|
if peer_id != _peer_id:
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user