修复摄像机穿模
This commit is contained in:
@@ -10,6 +10,8 @@ extends CharacterBody3D
|
||||
## 本脚本不实现任何操作,只负责「谁先谁后」和「谁有权跑」。
|
||||
|
||||
@onready var body: Node3D = $Body
|
||||
## 本地玩家自己的模型(鼠)。第一人称要藏掉它,见 _ready()。
|
||||
@onready var model: Node3D = get_node_or_null("Body/mouse") as Node3D
|
||||
@onready var camera_rig: Node3D = $CameraRig
|
||||
@onready var camera: Camera3D = $CameraRig/Camera
|
||||
## 准心(挂在 CameraRig/HUD 下)。远端玩家的 HUD 会随 camera_rig 一起被释放。
|
||||
@@ -37,6 +39,12 @@ func _ready() -> void:
|
||||
pickup.set_process_unhandled_input(false)
|
||||
return
|
||||
|
||||
# 第一人称:藏掉自己的模型。
|
||||
# 摄像机的近裁剪面被调小了(见 player.tscn 的 near = 0.01),已经盖不住自己的身体 ——
|
||||
# 不藏就会从内部看到模型的内壁。远端玩家的模型是各自独立的实例,不受影响。
|
||||
if model != null:
|
||||
model.visible = false
|
||||
|
||||
# 依赖注入:组件不自己去 get_node,由这里接线。
|
||||
# 好处是组件不认识玩家的场景结构,换场景 / 单测时注入别的节点即可。
|
||||
look.setup(camera_rig, camera, body)
|
||||
|
||||
@@ -36,6 +36,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0)
|
||||
|
||||
[node name="Camera" type="Camera3D" parent="CameraRig" unique_id=52294557]
|
||||
transform = Transform3D(10.406274, 0, 0, 0, 10.406274, 0, 0, 0, 10.406274, 0, -0.6916404, -0.11179829)
|
||||
near = 0.01
|
||||
|
||||
[node name="InteractionRay" type="RayCast3D" parent="CameraRig/Camera" unique_id=388601766]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
|
||||
|
||||
@@ -10,9 +10,9 @@ properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath(".:health")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath("Body/AnimationPlayer:anim_state")
|
||||
properties/3/path = NodePath("AnimationPlayer:anim_state")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 1
|
||||
properties/4/path = NodePath("Body/AnimationPlayer:anim_speed")
|
||||
properties/4/path = NodePath("AnimationPlayer:anim_speed")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 1
|
||||
|
||||
Reference in New Issue
Block a user