角色动画

This commit is contained in:
2026-09-23 16:27:02 +08:00
parent 414fcafe1d
commit 6355ac41a5
18 changed files with 3260 additions and 77 deletions
+3 -2
View File
@@ -3,8 +3,9 @@ extends Node3D
##
## 只做一件事:把玩家场景注册给 MultiplayerSpawner,并把 spawner 托管给 Net 单例。
## 玩家的生成/回收时机完全由 Net 决定,本文件不主动调用 spawn。
@export
var player_scene: PackedScene
const PLAYER_SCENE: PackedScene = preload("res://player/player.tscn")
const PLAYER_GROUP: String = "net_player"
## 用节点路径而不是全局标识符访问单例:
## autoload 的全局名只在引擎启动时注册,这样写不依赖注册时机。
@@ -26,7 +27,7 @@ func _ready() -> void:
## 这样「谁是本地玩家」在各端结论一致,玩家脚本里的 is_multiplayer_authority() 才可靠。
## recursive=true 很关键 —— 节点 authority 不自动继承,Sync 子节点必须一起设。
func _create_player(peer_id: int) -> Node:
var player := PLAYER_SCENE.instantiate()
var player := player_scene.instantiate()
player.name = str(peer_id)
player.add_to_group(PLAYER_GROUP)
player.set_multiplayer_authority(peer_id, true)
+2
View File
@@ -1,6 +1,7 @@
[gd_scene format=3 uid="uid://bp8l1uwgshc86"]
[ext_resource type="Script" uid="uid://11rbhffe5dhv" path="res://world/main.gd" id="1_hyim0"]
[ext_resource type="PackedScene" uid="uid://bekuuw153mv03" path="res://character/player/player.tscn" id="2_4f7fj"]
[ext_resource type="Sky" uid="uid://bi632suyifms5" path="res://world/sky/cartoon_sky.tres" id="2_cartoon"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hyim0"]
@@ -23,6 +24,7 @@ reflected_light_source = 2
[node name="Main" type="Node3D" unique_id=58155864]
script = ExtResource("1_hyim0")
player_scene = ExtResource("2_4f7fj")
[node name="Ground" type="StaticBody3D" parent="." unique_id=305091665]