完善客户端功能并同步差距文档
This commit is contained in:
@@ -34,6 +34,13 @@ var _orbit_active := false # 已越过 deadzone
|
||||
var _orbit_press := Vector2.ZERO
|
||||
var _pinch_last := -1.0 # 上一帧两指间距,<0 = 未在捏合
|
||||
|
||||
# ClientVS22 game.py drives these while Q/E/R/F/T/G are held. Keeping the
|
||||
# state here (instead of applying one large step per key event) gives the
|
||||
# same continuous desktop-camera motion on macOS and Windows.
|
||||
var _key_orbit := 0
|
||||
var _key_zoom := 0
|
||||
var _key_pitch := 0
|
||||
|
||||
const OCCLUDER_MASK := 1 << 1 # 静态遮挡物层(Metin2World 给建筑的盒碰撞)
|
||||
const FADE_ALPHA := 0.72 # 挡住玩家时的透明度
|
||||
var _faded: Array[Node] = [] # 上一帧被淡出的 GeometryInstance3D
|
||||
@@ -108,6 +115,15 @@ func heading() -> float:
|
||||
# 相机看向的水平方向(供角色移动「相对相机」用)
|
||||
return yaw
|
||||
|
||||
func set_key_orbit(direction: int) -> void:
|
||||
_key_orbit = clampi(direction, -1, 1)
|
||||
|
||||
func set_key_zoom(direction: int) -> void:
|
||||
_key_zoom = clampi(direction, -1, 1)
|
||||
|
||||
func set_key_pitch(direction: int) -> void:
|
||||
_key_pitch = clampi(direction, -1, 1)
|
||||
|
||||
func _desired_pos(snap := false) -> Vector3:
|
||||
var head := target.global_position + head_offset
|
||||
var off := Vector3(
|
||||
@@ -146,6 +162,12 @@ func shake(strength: float, decay := 8.0) -> void:
|
||||
func _process(dt: float) -> void:
|
||||
if target == null:
|
||||
return
|
||||
if _key_orbit != 0:
|
||||
yaw += float(_key_orbit) * dt * 1.8
|
||||
if _key_zoom != 0:
|
||||
dist = clampf(dist + float(_key_zoom) * dt * 5.0, min_dist, max_dist)
|
||||
if _key_pitch != 0:
|
||||
pitch = clampf(pitch + float(_key_pitch) * dt * 1.2, min_pitch, max_pitch)
|
||||
var want := _desired_pos()
|
||||
if _pos_ready:
|
||||
global_position = global_position.lerp(want, clampf(follow_lerp * dt, 0.0, 1.0))
|
||||
|
||||
Reference in New Issue
Block a user