Update REAME
This commit is contained in:
181
README.md
181
README.md
@@ -140,108 +140,106 @@ Hệ thống điều khiển nhân vật không chỉ quản lý hành động m
|
|||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
direction TB
|
direction TB
|
||||||
|
|
||||||
%% Định nghĩa các Style giả lập qua ghi chú (vì stateDiagram-v2 hạn chế classDef trực tiếp)
|
%% Định nghĩa các vùng trạng thái
|
||||||
|
state "🌸 GROUND LOCOMOTION" as Ground {
|
||||||
state "🕹️ GROUND LOCOMOTION (STEALTH & SPEED)" as Ground {
|
|
||||||
[*] --> Idle
|
[*] --> Idle
|
||||||
|
|
||||||
state Idle {
|
state Idle {
|
||||||
direction LR
|
direction LR
|
||||||
I_Phys: Vel < 0.1m/s
|
I_Phys: 📝 Vel < 0.1m/s
|
||||||
I_Cam: Breathing Cycle (0.5Hz)
|
I_Cam: 🌡️ Breathing Cycle (0.5Hz)
|
||||||
}
|
}
|
||||||
|
|
||||||
Idle --> Moving: Input.mag > 0.1
|
Idle --> Moving: "Input.mag > 0.1"
|
||||||
state Moving {
|
state Moving {
|
||||||
direction LR
|
direction LR
|
||||||
M_Phys: Speed 2-4m/s
|
M_Phys: 👟 Speed 2-4m/s
|
||||||
M_Cam: Head Bob (1.2Hz, Amp 0.05)
|
M_Cam: 🎢 Head Bob (1.2Hz)
|
||||||
}
|
}
|
||||||
|
|
||||||
Moving --> Sneaking: OnSneak (Hold)
|
Moving --> Sneaking: "OnSneak (Hold) ✨"
|
||||||
state Sneaking {
|
state Sneaking {
|
||||||
direction LR
|
direction LR
|
||||||
Sn_Phys: Speed 1.5m/s | Noise -50%
|
Sn_Phys: 🤫 Speed 1.5m/s | Noise -50%
|
||||||
Sn_Cam: Height -0.5m | FOV 55 (Focus)
|
Sn_Cam: 📉 Height -0.5m | FOV 55
|
||||||
}
|
}
|
||||||
|
|
||||||
Moving --> Sprinting: OnSprint (Hold) && Stamina > 0
|
Moving --> Sprinting: "OnSprint (Hold) 🔥"
|
||||||
state Sprinting {
|
state Sprinting {
|
||||||
direction LR
|
direction LR
|
||||||
Sp_Phys: Speed > 6.5m/s | Noise +100%
|
Sp_Phys: ⚡ Speed > 6.5m/s | Noise +100%
|
||||||
Sp_Cam: FOV 60->85 (Dynamic) | Motion Blur
|
Sp_Cam: 🌈 Dynamic FOV (60-85)
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprinting --> Moving: Stamina == 0 || !SprintInput
|
Sprinting --> Moving: "Stamina == 0 or Release"
|
||||||
Sneaking --> Moving: !SneakInput
|
Sneaking --> Moving: "Release Sneak"
|
||||||
}
|
}
|
||||||
|
|
||||||
state "🌪️ AIRBORNE & KINETIC IMPACT" as Air {
|
state "☁️ AIRBORNE & IMPACT" as Air {
|
||||||
state Jump {
|
state Jump {
|
||||||
J_Phys: AddForce(Vector3.up * Power)
|
J_Phys: 🆙 AddForce Up
|
||||||
J_Cam: Instant Y-Kick (Recoil)
|
J_Cam: 🚀 Instant Y-Kick
|
||||||
}
|
}
|
||||||
|
|
||||||
state Falling {
|
state Falling {
|
||||||
F_Phys: Gravity * 1.5 (Fast Fall)
|
F_Phys: 📉 Gravity x 1.5
|
||||||
F_Cam: FOV Stretch | Wind SFX
|
F_Cam: 💨 Wind Distortion VFX
|
||||||
}
|
}
|
||||||
|
|
||||||
state Landing {
|
state Landing {
|
||||||
L_Phys: Impact Velocity Check
|
L_Phys: 📏 Impact Velocity Check
|
||||||
L_Cam: Hard/Soft Shake (Z-Axis Roll)
|
L_Cam: 💢 Screen Shake
|
||||||
}
|
}
|
||||||
|
|
||||||
Jump --> Falling: Vel.y < 0
|
Jump --> Falling: "Velocity.y < 0"
|
||||||
Falling --> Landing: IsGrounded == true
|
Falling --> Landing: "IsGrounded == true"
|
||||||
}
|
}
|
||||||
|
|
||||||
state "⚡ ACTION & ABILITY LAYER" as Utility {
|
state "🎀 UTILITY & ACTIONS" as Utility {
|
||||||
state Dashing {
|
state Dashing {
|
||||||
D_Phys: Linear Velocity Burst (15m/s)
|
D_Phys: 💨 Burst 15m/s
|
||||||
D_Cam: Lens Distortion (Radial) | Trail VFX
|
D_Cam: 🍭 Lens Distortion
|
||||||
}
|
}
|
||||||
|
|
||||||
state Interacting {
|
state Interacting {
|
||||||
Int_Phys: Root Motion Lock
|
Int_Phys: 🔒 Root Motion Lock
|
||||||
Int_Cam: Contextual Smooth Look-at
|
Int_Cam: 👁️ Contextual Look-at
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state "🌐 NETWORK RECONCILIATION LAYER" as Net {
|
state "🌐 NETWORK SYNC (Fusion)" as Net {
|
||||||
state InputAuthority {
|
state InputAuthority {
|
||||||
IA: Local Prediction (Zero Latency)
|
IA: 🎮 Local Prediction
|
||||||
IA: Buffer Tick N
|
IA: ⏳ Buffer Tick N
|
||||||
}
|
}
|
||||||
state StateAuthority {
|
state StateAuthority {
|
||||||
SA: Server Snapshot (Tick N-3)
|
SA: 🖥️ Server Snapshot
|
||||||
SA: Verification & Correction
|
SA: 🛠️ Reconciliation
|
||||||
}
|
}
|
||||||
|
|
||||||
IA --> SA: [Networked] CamRotation
|
IA --> SA: "[Networked] CamRotation"
|
||||||
SA --> IA: Teleport/Snap if Error > 0.5m
|
SA --> IA: "Correction if Error > 0.5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
%% Hệ thống góc nhìn bất đối xứng (Asymmetric Views)
|
state "🎭 ROLE VIEWPORTS" as Roles {
|
||||||
state "🎭 ROLE SPECIFIC VIEWPORTS" as Roles {
|
|
||||||
state Seeker_FPS {
|
state Seeker_FPS {
|
||||||
S_View: 1st Person POV
|
S_View: 🔦 1st Person POV
|
||||||
S_Logic: Raycast Flashlight | Noise Meter UI
|
S_Logic: 🔊 Noise Meter UI
|
||||||
}
|
}
|
||||||
state Trapper_STRAT {
|
state Trapper_STRAT {
|
||||||
T_View: Top-Down Orthographic / Isometric
|
T_View: 🗺️ Tactical Overlay
|
||||||
T_Logic: Heatmap Overlay | CCTV Switcher
|
T_Logic: 🌡️ Heatmap & CCTV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%% Transitions chính
|
%% Transitions chính (Đã sửa lỗi cú pháp bằng dấu "")
|
||||||
Ground --> Air: !IsGrounded (Coyote Time: 0.2s)
|
Ground --> Air: "!IsGrounded (Coyote Time: 0.2s)"
|
||||||
Air --> Ground: OnLand Event
|
Air --> Ground: "OnLand Event ✨"
|
||||||
Ground --> Utility: OnAbilityTrigger
|
Ground --> Utility: "OnAbilityTrigger ⚡"
|
||||||
Utility --> Ground: OnAnimationEnd
|
Utility --> Ground: "Action Complete ✅"
|
||||||
|
|
||||||
note left of Ground: Sync: [Networked] Velocity, MoveState
|
note left of Ground: 🎵 Sync: Velocity, MoveState
|
||||||
note right of Net: Fusion: FixedUpdateNetwork() Loop
|
note right of Net: ⚙️ Fusion: FixedUpdateNetwork Loop
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Environment Scanner & Interaction
|
### 2. Environment Scanner & Interaction
|
||||||
@@ -329,66 +327,63 @@ Sử dụng **Photon Fusion (State Sync)** với cơ chế Client-Side Predictio
|
|||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
autonumber
|
autonumber
|
||||||
|
|
||||||
%% Định nghĩa các bên tham gia với Icon
|
%% Định nghĩa các bên tham gia với phong cách đáng yêu
|
||||||
participant IR as 🖱️ Input Reader (Local)
|
participant IR as 🖱️ Input Reader
|
||||||
box rgb(235, 245, 255) "CLIENT (Input Authority)"
|
box "🌸 CLIENT (Authority)" #E3F2FD
|
||||||
participant CP as 👤 Local Player<br/>(Predictive Simulation)
|
participant CP as 🎀 Local Player<br/>(Predictive)
|
||||||
end
|
end
|
||||||
box rgb(255, 243, 224) "NETWORK LAYER"
|
box "🌐 NETWORK" #FFF3E0
|
||||||
participant NT as 🌐 Photon Fusion Buffer
|
participant NT as ✨ Fusion Buffer
|
||||||
end
|
end
|
||||||
box rgb(232, 245, 233) "SERVER (State Authority)"
|
box "🖥️ SERVER" #E8F5E9
|
||||||
participant S as 🖥️ Headless Server<br/>(Validation)
|
participant S as 👑 State Authority
|
||||||
end
|
end
|
||||||
box rgb(243, 229, 245) "OTHER CLIENTS (Proxies)"
|
box "👥 OTHERS" #F3E5F5
|
||||||
participant RP as 👥 Remote Proxies<br/>(Interpolation)
|
participant RP as 🍭 Remote Proxies
|
||||||
end
|
end
|
||||||
|
|
||||||
%% --- GIAI ĐOẠN 1: THU THẬP INPUT ---
|
%% --- GIAI ĐOẠN 1: THU THẬP ---
|
||||||
rect rgb(200, 230, 250)
|
Note over IR, CP: [TICK N] Thu thập năng lượng Input ✨
|
||||||
Note over IR, CP: [TICK N] Giai đoạn lấy dữ liệu đầu vào
|
IR->>CP: OnMove / OnJump Events
|
||||||
IR->>CP: OnMove(Vector2), OnJump(bool)
|
CP->>CP: 📦 Encode NetworkInputData
|
||||||
CP->>CP: Encode NetworkInputData {Buttons, Angles}
|
|
||||||
|
%% --- 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
|
||||||
end
|
end
|
||||||
|
|
||||||
%% --- GIAI ĐOẠN 2: DỰ ĐOÁN & GỬI DỮ LIỆU ---
|
%% --- GIAI ĐOẠN 3: XÁC THỰC ---
|
||||||
rect rgb(255, 248, 225)
|
rect rgb(235, 255, 235)
|
||||||
Note over CP, NT: [FixedUpdateNetwork] Khởi chạy vòng lặp mạng
|
Note right of S: SERVER LOGIC (Tick N) ⚖️
|
||||||
CP->>CP: 🏃 Client-Side Prediction:<br/>Áp dụng vận tốc & Physics ngay lập tức
|
S->>S: 📝 Verify Input & Collision
|
||||||
CP->>NT: Reliable/Unreliable Input Packet
|
S->>S: 💾 Update [Networked] States
|
||||||
NT-->>S: Transport Layer (UDP/Photon Bolt)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%% --- GIAI ĐOẠN 3: XÁC THỰC TẠI SERVER ---
|
%% --- GIAI ĐOẠN 4: ĐỒNG BỘ ---
|
||||||
rect rgb(232, 245, 233)
|
S-->>NT: 📣 Broadcast State Snapshot
|
||||||
Note right of S: SERVER SIMULATION (Tick N)
|
|
||||||
S->>S: Dequeue Input từ Buffer
|
|
||||||
S->>S: Thực thi Logic: Move -> Collision Check -> Stamina
|
|
||||||
S->>S: Ghi đè [Networked] Properties (State Authority)
|
|
||||||
end
|
|
||||||
|
|
||||||
%% --- GIAI ĐOẠN 4: ĐỒNG BỘ HÓA & HIỆU CHỈNH ---
|
par 💫 Hồi đáp Local Player
|
||||||
S-->>NT: Broadcast State Snapshot (Tick N)
|
|
||||||
|
|
||||||
par Hồi đáp Local Player
|
|
||||||
NT-->>CP: State Snapshot
|
NT-->>CP: State Snapshot
|
||||||
Note over CP: 🔄 RECONCILIATION
|
Note over CP: 🔄 RECONCILIATION
|
||||||
alt Nếu vị trí sai lệch > Threshold
|
alt ⚠️ Sai lệch > Threshold
|
||||||
CP->>CP: Hard Snap / Resimulate từ Tick lỗi
|
CP->>CP: Hard Snap & Resimulate
|
||||||
else Khớp dữ liệu
|
else ✅ Hợp lệ
|
||||||
CP->>CP: Tiếp tục Simulation
|
CP->>CP: Tiếp tục Simulation mượt mà
|
||||||
end
|
end
|
||||||
and Cập nhật các Player khác
|
and 🌈 Cập nhật cho mọi người
|
||||||
NT-->>RP: State Snapshot
|
NT-->>RP: State Snapshot
|
||||||
Note over RP: 🎞️ INTERPOLATION
|
Note over RP: 🎞️ INTERPOLATION
|
||||||
RP->>RP: Lerp từ Snapshot (N-1) sang Snapshot (N)
|
RP->>RP: Lerp(Snap_N, Snap_N-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
%% --- GIAI ĐOẠN 5: HIỂN THỊ (MONOBEHAVIOUR) ---
|
%% --- GIAI ĐOẠN 5: HIỂN THỊ ---
|
||||||
rect rgb(245, 245, 245)
|
rect rgb(250, 240, 255)
|
||||||
Note over CP, RP: [LateUpdate / Render Loop]
|
Note over CP, RP: [LateUpdate] Rendering Kawaii VFX 🎨
|
||||||
CP->>CP: Update Visual: Camera Shake, VFX
|
CP->>CP: Cam Shake & Particles
|
||||||
RP->>RP: Render Smooth Mesh Motion
|
RP->>RP: Smooth Mesh Movement
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user