Skip to content

Commit 62184da

Browse files
authored
fix(example): Smooth aiming input on FPS examples (#509)
Fixes #498
1 parent 81c1c30 commit 62184da

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

examples/multiplayer-fps/characters/player.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ properties = Array[String]([":transform", "Head:transform"])
143143

144144
[node name="Input" type="Node" parent="." node_paths=PackedStringArray("big_gun", "hud")]
145145
script = ExtResource("10_50d5g")
146+
mouse_sensitivity = 0.005
146147
big_gun = NodePath("../Head/BigGun")
147148
hud = NodePath("../HUD")
148149

examples/multiplayer-fps/scripts/player-input.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func _input(event: InputEvent) -> void:
2727
if !is_multiplayer_authority(): return
2828

2929
if event is InputEventMouseMotion:
30-
mouse_rotation.y = event.relative.x * mouse_sensitivity
31-
mouse_rotation.x = event.relative.y * mouse_sensitivity
30+
mouse_rotation.y += event.relative.x * mouse_sensitivity
31+
mouse_rotation.x += event.relative.y * mouse_sensitivity
3232

3333
if event.is_action_pressed("escape"):
3434
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
@@ -51,7 +51,7 @@ func _gather():
5151
look_angle = Vector2.ZERO
5252
mouse_rotation = Vector2.ZERO
5353
else:
54-
look_angle = Vector2(-mouse_rotation.y * NetworkTime.ticktime, -mouse_rotation.x * NetworkTime.ticktime)
54+
look_angle = Vector2(-mouse_rotation.y, -mouse_rotation.x)
5555
mouse_rotation = Vector2.ZERO
5656

5757
func setup():

examples/rollback-fps/characters/player.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ properties = Array[String]([":transform", "Head:transform"])
9191

9292
[node name="Input" type="Node" parent="."]
9393
script = ExtResource("7_2i3bi")
94+
mouse_sensitivity = 0.005
9495

9596
[node name="Hit SFX" type="AudioStreamPlayer3D" parent="."]
9697
stream = ExtResource("15_1n4tg")

examples/rollback-fps/scripts/player-input.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func _input(event: InputEvent) -> void:
1919
if !is_multiplayer_authority(): return
2020

2121
if event is InputEventMouseMotion:
22-
mouse_rotation.y = event.relative.x * mouse_sensitivity
23-
mouse_rotation.x = event.relative.y * mouse_sensitivity
22+
mouse_rotation.y += event.relative.x * mouse_sensitivity
23+
mouse_rotation.x += event.relative.y * mouse_sensitivity
2424

2525
if event.is_action_pressed("escape"):
2626
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
@@ -44,5 +44,5 @@ func _gather():
4444
look_angle = Vector2.ZERO
4545
mouse_rotation = Vector2.ZERO
4646
else:
47-
look_angle = Vector2(-mouse_rotation.y * NetworkTime.ticktime, -mouse_rotation.x * NetworkTime.ticktime)
47+
look_angle = Vector2(-mouse_rotation.y, -mouse_rotation.x)
4848
mouse_rotation = Vector2.ZERO

0 commit comments

Comments
 (0)