bru
This commit is contained in:
175
README.md
175
README.md
@@ -140,106 +140,75 @@ Hệ thống điều khiển nhân vật không chỉ quản lý hành động m
|
||||
stateDiagram-v2
|
||||
direction TB
|
||||
|
||||
%% Định nghĩa các vùng trạng thái
|
||||
state "🌸 GROUND LOCOMOTION" as Ground {
|
||||
[*] --> Idle
|
||||
|
||||
state Idle {
|
||||
direction LR
|
||||
I_Phys: 📝 Vel < 0.1m/s
|
||||
I_Cam: 🌡️ Breathing Cycle (0.5Hz)
|
||||
I_P: 📝 Vel < 0.1m/s
|
||||
I_C: 🌡️ Breathing (0.5Hz)
|
||||
}
|
||||
|
||||
Idle --> Moving: "Input.mag > 0.1"
|
||||
Idle --> Moving : "Input.mag > 0.1"
|
||||
state Moving {
|
||||
direction LR
|
||||
M_Phys: 👟 Speed 2-4m/s
|
||||
M_Cam: 🎢 Head Bob (1.2Hz)
|
||||
M_P: 👟 Speed 2-4m/s
|
||||
M_C: 🎢 Head Bob (1.2Hz)
|
||||
}
|
||||
|
||||
Moving --> Sneaking: "OnSneak (Hold) ✨"
|
||||
Moving --> Sneaking : "OnSneak (Hold)"
|
||||
state Sneaking {
|
||||
direction LR
|
||||
Sn_Phys: 🤫 Speed 1.5m/s | Noise -50%
|
||||
Sn_Cam: 📉 Height -0.5m | FOV 55
|
||||
Sn_P: 🤫 Noise -50%
|
||||
Sn_C: 📉 Lower Height
|
||||
}
|
||||
|
||||
Moving --> Sprinting: "OnSprint (Hold) 🔥"
|
||||
Moving --> Sprinting : "OnSprint (Hold)"
|
||||
state Sprinting {
|
||||
direction LR
|
||||
Sp_Phys: ⚡ Speed > 6.5m/s | Noise +100%
|
||||
Sp_Cam: 🌈 Dynamic FOV (60-85)
|
||||
Sp_P: ⚡ Speed > 6.5m/s
|
||||
Sp_C: 🌈 Dynamic FOV
|
||||
}
|
||||
|
||||
Sprinting --> Moving: "Stamina == 0 or Release"
|
||||
Sneaking --> Moving: "Release Sneak"
|
||||
Sprinting --> Moving : "Stamina Empty"
|
||||
Sneaking --> Moving : "Release Sneak"
|
||||
}
|
||||
|
||||
state "☁️ AIRBORNE & IMPACT" as Air {
|
||||
state Jump {
|
||||
J_Phys: 🆙 AddForce Up
|
||||
J_Cam: 🚀 Instant Y-Kick
|
||||
J_P: 🆙 AddForce Up
|
||||
}
|
||||
|
||||
state Falling {
|
||||
F_Phys: 📉 Gravity x 1.5
|
||||
F_Cam: 💨 Wind Distortion VFX
|
||||
F_P: 📉 Gravity x 1.5
|
||||
}
|
||||
|
||||
state Landing {
|
||||
L_Phys: 📏 Impact Velocity Check
|
||||
L_Cam: 💢 Screen Shake
|
||||
L_P: 📏 Impact Check
|
||||
}
|
||||
|
||||
Jump --> Falling: "Velocity.y < 0"
|
||||
Falling --> Landing: "IsGrounded == true"
|
||||
Jump --> Falling : "Vel.y < 0"
|
||||
Falling --> Landing : "IsGrounded == true"
|
||||
}
|
||||
|
||||
state "🎀 UTILITY & ACTIONS" as Utility {
|
||||
state "⚡ ACTION LAYER" as Utility {
|
||||
state Dashing {
|
||||
D_Phys: 💨 Burst 15m/s
|
||||
D_Cam: 🍭 Lens Distortion
|
||||
D_P: 💨 Burst 15m/s
|
||||
}
|
||||
|
||||
state Interacting {
|
||||
Int_Phys: 🔒 Root Motion Lock
|
||||
Int_Cam: 👁️ Contextual Look-at
|
||||
Int_P: 🔒 Root Motion Lock
|
||||
}
|
||||
}
|
||||
|
||||
state "🌐 NETWORK SYNC (Fusion)" as Net {
|
||||
state InputAuthority {
|
||||
IA: 🎮 Local Prediction
|
||||
IA: ⏳ Buffer Tick N
|
||||
}
|
||||
state StateAuthority {
|
||||
SA: 🖥️ Server Snapshot
|
||||
SA: 🛠️ Reconciliation
|
||||
}
|
||||
|
||||
IA --> SA: "[Networked] CamRotation"
|
||||
SA --> IA: "Correction if Error > 0.5m"
|
||||
state "🌐 NETWORK SYNC" as Net {
|
||||
state "Input Authority" as IA
|
||||
state "State Authority" as SA
|
||||
IA --> SA : "Send [Networked] Rotation"
|
||||
SA --> IA : "Reconciliation if Error"
|
||||
}
|
||||
|
||||
state "🎭 ROLE VIEWPORTS" as Roles {
|
||||
state Seeker_FPS {
|
||||
S_View: 🔦 1st Person POV
|
||||
S_Logic: 🔊 Noise Meter UI
|
||||
}
|
||||
state Trapper_STRAT {
|
||||
T_View: 🗺️ Tactical Overlay
|
||||
T_Logic: 🌡️ Heatmap & CCTV
|
||||
}
|
||||
}
|
||||
%% Transitions chính - Đã sửa lỗi tại đây ✨
|
||||
Ground --> Air : "IsGrounded == false"
|
||||
Air --> Ground : "OnLand Event"
|
||||
Ground --> Utility : "OnAbilityTrigger"
|
||||
Utility --> Ground : "Action Complete"
|
||||
|
||||
%% Transitions chính (Đã sửa lỗi cú pháp bằng dấu "")
|
||||
Ground --> Air: "!IsGrounded (Coyote Time: 0.2s)"
|
||||
Air --> Ground: "OnLand Event ✨"
|
||||
Ground --> Utility: "OnAbilityTrigger ⚡"
|
||||
Utility --> Ground: "Action Complete ✅"
|
||||
|
||||
note left of Ground: 🎵 Sync: Velocity, MoveState
|
||||
note right of Net: ⚙️ Fusion: FixedUpdateNetwork Loop
|
||||
note left of Ground : ✨ Sync: Velocity, MoveState
|
||||
note right of Net : ⚙️ Fusion: FixedUpdateNetwork
|
||||
```
|
||||
|
||||
### 2. Environment Scanner & Interaction
|
||||
@@ -327,64 +296,52 @@ Sử dụng **Photon Fusion (State Sync)** với cơ chế Client-Side Predictio
|
||||
sequenceDiagram
|
||||
autonumber
|
||||
|
||||
%% Định nghĩa các bên tham gia với phong cách đáng yêu
|
||||
participant IR as 🖱️ Input Reader
|
||||
box "🌸 CLIENT (Authority)" #E3F2FD
|
||||
participant CP as 🎀 Local Player<br/>(Predictive)
|
||||
participant IR as 🖱️ Input
|
||||
box #E3F2FD "CLIENT"
|
||||
participant CP as 🎀 Local Player
|
||||
end
|
||||
box "🌐 NETWORK" #FFF3E0
|
||||
participant NT as ✨ Fusion Buffer
|
||||
box #FFF3E0 "NET"
|
||||
participant NT as ✨ Fusion
|
||||
end
|
||||
box "🖥️ SERVER" #E8F5E9
|
||||
participant S as 👑 State Authority
|
||||
box #E8F5E9 "SERVER"
|
||||
participant S as 👑 Authority
|
||||
end
|
||||
box "👥 OTHERS" #F3E5F5
|
||||
participant RP as 🍭 Remote Proxies
|
||||
box #F3E5F5 "OTHERS"
|
||||
participant RP as 🍭 Proxies
|
||||
end
|
||||
|
||||
%% --- GIAI ĐOẠN 1: THU THẬP ---
|
||||
Note over IR, CP: [TICK N] Thu thập năng lượng Input ✨
|
||||
IR->>CP: OnMove / OnJump Events
|
||||
CP->>CP: 📦 Encode NetworkInputData
|
||||
Note over IR, CP: [TICK N] Thu thập Input ✨
|
||||
IR->>CP: OnMove / OnJump
|
||||
CP->>CP: 📦 Pack NetworkInputData
|
||||
|
||||
%% --- GIAI ĐOẠN 2: DỰ ĐOÁN ---
|
||||
rect rgb(255, 245, 230)
|
||||
Note over CP, NT: [FixedUpdateNetwork] Chạy trước tương lai! 🚀
|
||||
CP->>CP: 🏃 Client-Side Prediction<br/>(Di chuyển ngay lập tức)
|
||||
CP->>NT: ✉️ Send Input Packet
|
||||
NT-->>S: Transport via UDP
|
||||
rect rgb(255, 250, 240)
|
||||
Note over CP, NT: Prediction Mode 🚀
|
||||
CP->>CP: 🏃 Client-Side Prediction
|
||||
CP->>NT: ✉️ Send Packet
|
||||
NT-->>S: UDP Transport
|
||||
end
|
||||
|
||||
%% --- GIAI ĐOẠN 3: XÁC THỰC ---
|
||||
rect rgb(235, 255, 235)
|
||||
Note right of S: SERVER LOGIC (Tick N) ⚖️
|
||||
S->>S: 📝 Verify Input & Collision
|
||||
S->>S: 💾 Update [Networked] States
|
||||
rect rgb(240, 255, 240)
|
||||
Note right of S: SERVER VALIDATION ⚖️
|
||||
S->>S: 📝 Check Collision & Move
|
||||
S->>S: 💾 Update [Networked] State
|
||||
end
|
||||
|
||||
%% --- GIAI ĐOẠN 4: ĐỒNG BỘ ---
|
||||
S-->>NT: 📣 Broadcast State Snapshot
|
||||
S-->>NT: 📣 Broadcast Snapshot
|
||||
|
||||
par 💫 Hồi đáp Local Player
|
||||
NT-->>CP: State Snapshot
|
||||
Note over CP: 🔄 RECONCILIATION
|
||||
alt ⚠️ Sai lệch > Threshold
|
||||
CP->>CP: Hard Snap & Resimulate
|
||||
else ✅ Hợp lệ
|
||||
CP->>CP: Tiếp tục Simulation mượt mà
|
||||
end
|
||||
and 🌈 Cập nhật cho mọi người
|
||||
NT-->>RP: State Snapshot
|
||||
Note over RP: 🎞️ INTERPOLATION
|
||||
RP->>RP: Lerp(Snap_N, Snap_N-1)
|
||||
par 💫 To Local
|
||||
NT-->>CP: Snapshot
|
||||
Note over CP: 🔄 RECONCILE
|
||||
and 🌈 To Proxies
|
||||
NT-->>RP: Snapshot
|
||||
Note over RP: 🎞️ INTERPOLATE
|
||||
end
|
||||
|
||||
%% --- GIAI ĐOẠN 5: HIỂN THỊ ---
|
||||
rect rgb(250, 240, 255)
|
||||
Note over CP, RP: [LateUpdate] Rendering Kawaii VFX 🎨
|
||||
CP->>CP: Cam Shake & Particles
|
||||
RP->>RP: Smooth Mesh Movement
|
||||
end
|
||||
rect rgb(250, 245, 255)
|
||||
Note over CP, RP: [LateUpdate] Rendering 🎨
|
||||
CP->>CP: Camera Shake
|
||||
RP->>RP: Smooth Mesh Lerp
|
||||
end
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user