move aiming processing to physics process to fix jitter

This commit is contained in:
2025-07-27 05:10:58 +10:00
parent f36113d64c
commit aef30cbd88
6 changed files with 131 additions and 124 deletions

View File

@@ -14,7 +14,7 @@ func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
if not Referencer.players or not Referencer.main_camera:
var mouse_pos := get_viewport().get_mouse_position()
_single_cursor.position = mouse_pos - _single_cursor.size / 2
@@ -22,6 +22,8 @@ func _process(delta: float) -> void:
return
_single_cursor.visible = false
func _physics_process(delta: float) -> void:
call_deferred("_handle_cursors", delta)
@@ -87,6 +89,10 @@ func _handle_cursor(player_index: int, delta: float) -> void:
)
cursor.base.modulate = player.cursor_color
if player.input_mode_is(Inputer.Mode.KB_MOUSE):
cursor.base.position = (
get_viewport().get_mouse_position() - cursor.base.size / 2
)
class PlayerCursor:

View File

@@ -13,11 +13,11 @@ extends Camera3D
@export_group("Damage shake")
@export var _damage_shake_duration: float = 0.5
@export_exp_easing var _damage_shake_ease: float = 2
@export var _damage_shake_amplitude: float = 0.02
@export var _damage_shake_amplitude: float = 0.1
@export var _damage_shake_frequency: float = 50
@export_group("Hit shake")
@export var _hit_shake_fov: float = 0.5
@export var _hit_shake_fov: float = 1
@export var _hit_shake_duration: float = 0.5
@export_exp_easing var _hit_shake_ease: float = 4
@@ -40,6 +40,9 @@ func _process(delta: float) -> void:
fov = _fov
_damage_shake(delta)
_hit_shake(delta)
func _physics_process(delta: float) -> void:
call_deferred("_process_following", delta)

View File

@@ -27,7 +27,6 @@ func _ready() -> void:
func _process(_delta: float) -> void:
call_deferred("_aiming")
var aim_pos := global_position + aiming.aim_offset
Debugger.marker("aim", aim_pos + Vector3.UP)
@@ -35,6 +34,7 @@ func _process(_delta: float) -> void:
func _physics_process(delta: float) -> void:
_aiming()
var can_move := not attack.is_hitting()
velocity = movement.movement(velocity, delta, is_on_floor(), can_move)