decouple camera from runner position
This commit is contained in:
+13
-12
@@ -9,7 +9,7 @@ extends CharacterBody3D
|
||||
|
||||
@export_group("Camera")
|
||||
@export_range(0.0, 1.0) var mouse_sensitivity := 0.2
|
||||
@export var camera_follow_speed := 10.0
|
||||
@export var camera_follow_speed := 20.0
|
||||
@export var smooth_camera := false
|
||||
|
||||
@export_group("Movement")
|
||||
@@ -21,11 +21,11 @@ extends CharacterBody3D
|
||||
|
||||
@export_group("Client Tweening")
|
||||
@export var client_smoothing := false
|
||||
@export var client_smoothing_speed := 5.0
|
||||
@export var client_smoothing_rotation_speed := 10.0
|
||||
@export var client_smoothing_speed := 10.0
|
||||
@export var client_smoothing_rotation_speed := 25.0
|
||||
|
||||
@onready var _camera_pivot: Node3D = %CameraPivot
|
||||
@onready var _camera_target: Node3D = %CameraTarget
|
||||
@onready var _camera_platform: Node3D = %CameraPlatform
|
||||
@onready var _camera: Node3D = %Camera
|
||||
@onready var skin: Node3D = %Skin
|
||||
|
||||
@@ -59,6 +59,15 @@ func _input(event: InputEvent) -> void:
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
camera_input_direction += event.screen_relative * mouse_sensitivity
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if multiplayer.get_unique_id() == player_id:
|
||||
_camera_platform.global_rotation = _camera_pivot.global_rotation
|
||||
|
||||
if smooth_camera:
|
||||
_camera_platform.global_position = lerp(_camera_platform.global_position, _camera_pivot.global_position, camera_follow_speed * delta)
|
||||
else:
|
||||
_camera_platform.global_position = _camera_pivot.global_position
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
state_machine.process_physics(delta)
|
||||
if multiplayer.get_unique_id() == player_id:
|
||||
@@ -67,15 +76,7 @@ func _physics_process(delta: float) -> void:
|
||||
-PI / 3.0,
|
||||
PI / 6.0,
|
||||
)
|
||||
|
||||
_camera_pivot.rotation.y -= camera_input_direction.x * delta
|
||||
_camera.global_rotation = _camera_pivot.global_rotation
|
||||
|
||||
if smooth_camera:
|
||||
_camera.global_position = lerp(_camera.global_position, _camera_target.global_position, camera_follow_speed * delta)
|
||||
else:
|
||||
_camera.global_position = _camera_target.global_position
|
||||
|
||||
camera_input_direction = Vector2.ZERO
|
||||
|
||||
if not multiplayer.is_server():
|
||||
|
||||
Reference in New Issue
Block a user