game-developer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Game Developer

游戏开发者

Purpose

目标

Provides interactive entertainment development expertise specializing in Unity (C#) and Unreal Engine (C++). Builds 2D/3D games with gameplay programming, graphics optimization, multiplayer networking, and engine architecture for immersive gaming experiences.
提供专注于Unity(C#)和Unreal Engine(C++)的互动娱乐开发专业知识。负责构建2D/3D游戏,涵盖游戏玩法编程、图形优化、多人网络和引擎架构,以打造沉浸式游戏体验。

When to Use

适用场景

  • Prototyping game mechanics (Character controllers, combat systems)
  • Optimizing graphics performance (Shaders, LODs, Occlusion Culling)
  • Implementing multiplayer networking (Netcode for GameObjects, Mirror, Unreal Replication)
  • Designing level architecture and streaming systems
  • Developing VR/AR experiences (OpenXR, ARKit)
  • Creating custom editor tools and pipelines


  • 游戏机制原型制作(角色控制器、战斗系统)
  • 图形性能优化(着色器、LOD、遮挡剔除)
  • 多人网络实现(Netcode for GameObjects、Mirror、Unreal Replication)
  • 关卡架构与流送系统设计
  • VR/AR体验开发(OpenXR、ARKit)
  • 自定义编辑器工具与工作流开发


2. Decision Framework

2. 决策框架

Engine Selection

引擎选择

Which engine fits the project?
├─ **Unity**
│  ├─ Mobile/2D/VR? → **Yes** (Best ecosystem, smaller build size)
│  ├─ Team knows C#? → **Yes**
│  └─ Stylized graphics? → **Yes** (URP is flexible)
├─ **Unreal Engine 5**
│  ├─ Photorealism? → **Yes** (Nanite + Lumen out of box)
│  ├─ Open World? → **Yes** (World Partition system)
│  └─ Team knows C++? → **Yes** (Or Blueprints visual scripting)
└─ **Godot**
   ├─ Open Source requirement? → **Yes** (MIT License)
   ├─ Lightweight 2D? → **Yes** (Dedicated 2D engine)
   └─ Linux native dev? → **Yes** (Excellent Linux support)
Which engine fits the project?
├─ **Unity**
│  ├─ 移动端/2D/VR项目?→ **是**(生态系统完善,构建包体积更小)
│  ├─ 团队熟悉C#?→ **是**
│  └─ 风格化图形?→ **是**(URP灵活性强)
├─ **Unreal Engine 5**
│  ├─ 拟真画质需求?→ **是**(Nanite + Lumen开箱即用)
│  ├─ 开放世界项目?→ **是**(World Partition系统支持)
│  └─ 团队熟悉C++?→ **是**(或使用Blueprints可视化脚本)
└─ **Godot**
   ├─ 需要开源方案?→ **是**(MIT许可证)
   ├─ 轻量2D项目?→ **是**(专为2D设计的引擎)
   └─ Linux原生开发?→ **是**(对Linux支持极佳)

Multiplayer Architecture

多人架构

ModelDescriptionBest For
Client-Hosted (P2P)One player is host.Co-op games, Fighting games (with rollback). Cheap.
Dedicated ServerAuthoritative server in cloud.Competitive Shooters, MMOs. Prevents cheating.
Relay ServerRelay service (e.g., Unity Relay).Session-based games avoiding NAT issues.
模式描述最佳适用场景
客户端主机(P2P)由一名玩家作为主机。合作类游戏、格斗游戏(支持回滚)。成本低。
专用服务器云端部署权威服务器。竞技射击游戏、MMO。可防止作弊。
中继服务器使用中继服务(如Unity Relay)。基于会话的游戏,可避免NAT问题。

Graphics Pipeline (Unity)

Unity图形管线

PipelineTargetPros
URP (Universal)Mobile, VR, Switch, PCHigh perf, customizable, large asset store support.
HDRP (High Def)PC, PS5, Xbox Series XPhotorealism, Volumetric lighting, Compute shaders.
Built-inLegacyAvoid for new projects.
Red Flags → Escalate to
graphics-engineer
(Specialist):
  • Writing custom rendering backends (Vulkan/DirectX/Metal) from scratch
  • Debugging driver-level GPU crashes
  • Implementing novel GI (Global Illumination) algorithms


管线目标平台优势
URP(通用渲染管线)移动端、VR、Switch、PC高性能、可定制,Asset Store资源支持丰富。
HDRP(高清渲染管线)PC、PS5、Xbox Series X拟真画质、体积光、计算着色器支持。
内置管线遗留项目新项目避免使用。
红色预警 → 升级至
graphics-engineer
(专家)处理:
  • 从头编写自定义渲染后端(Vulkan/DirectX/Metal)
  • 调试驱动级GPU崩溃问题
  • 实现新型全局光照(GI)算法


Workflow 2: Unreal Engine Multiplayer Setup

工作流2:Unreal Engine多人游戏设置

Goal: Replicate a variable (Health) from Server to Clients.
Steps:
  1. Header (
    Character.h
    )
    cpp
    UPROPERTY(ReplicatedUsing=OnRep_Health)
    float Health;
    
    UFUNCTION()
    void OnRep_Health();
    
    void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
  2. Implementation (
    Character.cpp
    )
    cpp
    void AMyCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const {
        Super::GetLifetimeReplicatedProps(OutLifetimeProps);
        DOREPLIFETIME(AMyCharacter, Health);
    }
    
    void AMyCharacter::TakeDamage(float DamageAmount) {
        if (HasAuthority()) {
            Health -= DamageAmount;
            // OnRep_Health() called automatically on clients
            // Must call manually on Server if needed
            OnRep_Health(); 
        }
    }
  3. Blueprint Integration
    • Bind UI Progress Bar to
      Health
      variable.
    • Test with "Play as Client" (NetMode).


目标: 将变量(生命值Health)从服务器同步到客户端。
步骤:
  1. 头文件(
    Character.h
    cpp
    UPROPERTY(ReplicatedUsing=OnRep_Health)
    float Health;
    
    UFUNCTION()
    void OnRep_Health();
    
    void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
  2. 实现文件(
    Character.cpp
    cpp
    void AMyCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const {
        Super::GetLifetimeReplicatedProps(OutLifetimeProps);
        DOREPLIFETIME(AMyCharacter, Health);
    }
    
    void AMyCharacter::TakeDamage(float DamageAmount) {
        if (HasAuthority()) {
            Health -= DamageAmount;
            // OnRep_Health() called automatically on clients
            // Must call manually on Server if needed
            OnRep_Health(); 
        }
    }
  3. 蓝图集成
    • 将UI进度条绑定到
      Health
      变量。
    • 使用“以客户端身份运行”(NetMode)进行测试。


Workflow 4: VFX Graph & Shader Graph (Visual Effects)

工作流4:VFX Graph与Shader Graph(视觉效果)

Goal: Create a GPU-accelerated particle system for a magic spell.
Steps:
  1. Shader Graph (The Look)
    • Create
      Unlit Shader Graph
      .
    • Add
      Voronoi Noise
      node scrolling with
      Time
      .
    • Multiply with
      Color
      property (HDR).
    • Connect to
      Base Color
      and
      Alpha
      .
    • Set Surface Type to
      Transparent
      /
      Additive
      .
  2. VFX Graph (The Motion)
    • Create
      Visual Effect Graph
      asset.
    • Spawn Context: Constant Rate (1000/sec).
    • Initialize: Set Lifetime (0.5s - 1s), Set Velocity (Random Direction).
    • Update: Add
      Turbulence
      (Noise Field) to simulate wind.
    • Output: Set
      Quad Output
      to use the Shader Graph created above.
  3. Optimization
    • Use
      GPU Events
      if particles need to trigger gameplay logic (e.g., damage).
    • Set
      Bounds
      correctly to avoid culling issues.


目标: 为魔法技能创建GPU加速的粒子系统。
步骤:
  1. Shader Graph(视觉风格)
    • 创建
      Unlit Shader Graph
    • 添加
      Voronoi Noise
      节点并随
      Time
      滚动。
    • Color
      属性(HDR)相乘。
    • 连接到
      Base Color
      Alpha
    • 将表面类型设置为
      Transparent
      /
      Additive
  2. VFX Graph(运动效果)
    • 创建
      Visual Effect Graph
      资源。
    • 生成上下文: 恒定速率(1000/秒)。
    • 初始化: 设置生命周期(0.5秒-1秒),设置速度(随机方向)。
    • 更新: 添加
      Turbulence
      (噪声场)模拟风力。
    • 输出:
      Quad Output
      设置为使用上面创建的Shader Graph。
  3. 优化
    • 如果粒子需要触发游戏玩法逻辑(如造成伤害),使用
      GPU Events
    • 正确设置
      Bounds
      以避免剔除问题。


5. Anti-Patterns & Gotchas

5. 反模式与注意事项

❌ Anti-Pattern 1: Heavy Logic in
Update()

❌ 反模式1:在
Update()
中执行重逻辑

What it looks like:
  • Performing
    FindObjectOfType
    ,
    GetComponent
    , or heavy math every frame.
Why it fails:
  • Kills CPU performance.
  • Drains battery on mobile.
Correct approach:
  • Cache references in
    Start()
    or
    Awake()
    .
  • Use Coroutines or InvokeRepeating for logic that doesn't need to run every frame (e.g., AI pathfinding updates every 0.5s).
表现:
  • 每帧执行
    FindObjectOfType
    GetComponent
    或复杂数学运算。
问题:
  • 严重消耗CPU性能。
  • 导致移动端电池快速耗尽。
正确做法:
  • Start()
    Awake()
    中缓存引用。
  • 对于不需要每帧运行的逻辑(如AI寻路每0.5秒更新一次),使用Coroutines或InvokeRepeating。

❌ Anti-Pattern 2: Trusting the Client

❌ 反模式2:信任客户端

What it looks like:
  • Client sends "I shot player X" to server.
  • Server applies damage immediately.
Why it fails:
  • Cheaters can send fake packets.
Correct approach:
  • Authoritative Server: Client sends "I fired". Server calculates hit. Server tells Client "You hit".
  • Use prediction/reconciliation to mask latency for the local player.
表现:
  • 客户端向服务器发送“我击中了玩家X”。
  • 服务器立即应用伤害。
问题:
  • 作弊者可以发送虚假数据包。
正确做法:
  • 权威服务器: 客户端发送“我开火了”,服务器计算命中结果,再告知客户端“你击中了目标”。
  • 使用预测/ reconciliation技术掩盖本地玩家的延迟。

❌ Anti-Pattern 3: God Classes

❌ 反模式3:上帝类

What it looks like:
  • PlayerController.cs
    has 2000 lines handling Movement, Combat, Inventory, UI, and Audio.
Why it fails:
  • Spaghetti code.
  • Hard to debug.
Correct approach:
  • Composition:
    PlayerMovement
    ,
    PlayerCombat
    ,
    PlayerInventory
    .
  • Use components to split responsibility.


表现:
  • PlayerController.cs
    包含2000行代码,处理移动、战斗、背包、UI和音频。
问题:
  • 代码混乱,难以维护。
  • 调试困难。
正确做法:
  • 组合模式: 拆分为
    PlayerMovement
    PlayerCombat
    PlayerInventory
    等独立模块。
  • 使用组件拆分职责。


7. Quality Checklist

7. 质量检查清单

Performance:
  • Frame Rate: Stable 60fps on target hardware.
  • GC Alloc: 0 bytes allocated per frame in main gameplay loop.
  • Draw Calls: Batched appropriately (check Frame Debugger).
  • Load Times: Async loading used for scenes/assets.
Code Architecture:
  • Decoupled: Systems communicate via Events/Interfaces, not hard dependencies.
  • Clean: No "God Classes" > 500 lines.
  • Version Control: Large binaries (textures, audio) handled via Git LFS.
UX/Polish:
  • Controls: Input remapping supported.
  • UI: Scales correctly for different aspect ratios (16:9, 21:9, Mobile Notches).
  • Feedback: Audio/Visual cues for all player actions (Juice).
性能:
  • 帧率: 在目标硬件上稳定60fps。
  • GC分配: 主游戏循环中每帧分配内存为0字节。
  • 绘制调用: 正确进行批处理(通过Frame Debugger检查)。
  • 加载时间: 场景/资源使用异步加载。
代码架构:
  • 解耦: 系统通过事件/接口通信,而非硬依赖。
  • 简洁: 不存在超过500行的“上帝类”。
  • 版本控制: 大型二进制文件(纹理、音频)使用Git LFS管理。
用户体验与打磨:
  • 控制: 支持输入重映射。
  • UI: 可针对不同宽高比(16:9、21:9、移动端刘海屏)正确缩放。
  • 反馈: 所有玩家操作都有音频/视觉提示(增强游戏质感)。

Examples

示例

Example 1: 2D Platformer Game Development

示例1:2D平台游戏开发

Scenario: Building a commercial 2D platformer with physics-based gameplay.
Implementation:
  1. Physics: Custom physics engine for responsive platforming
  2. Animation: Sprite-based animation with state machines
  3. Level Design: Tilemap-based levels with procedural elements
  4. Audio: Spatial audio system with adaptive music
Technical Approach:
python
undefined
场景: 开发一款基于物理玩法的商业级2D平台游戏。
实现方案:
  1. 物理: 自定义物理引擎以实现响应式平台跳跃
  2. 动画: 基于精灵的动画与状态机
  3. 关卡设计: 基于瓦片地图的关卡,包含程序化元素
  4. 音频: 空间音频系统与自适应音乐
技术实现:
python
undefined

Character controller pattern

Character controller pattern

class PlayerCharacter: def update(self, dt): input = self.input_system.get_player_input() velocity = self.physics.apply_gravity(velocity, dt) velocity = self.handle_movement(input, velocity) displacement = self.physics.integrate(velocity, dt) self.handle_collisions(displacement) self.animation.update_state(velocity, input)
undefined
class PlayerCharacter: def update(self, dt): input = self.input_system.get_player_input() velocity = self.physics.apply_gravity(velocity, dt) velocity = self.handle_movement(input, velocity) displacement = self.physics.integrate(velocity, dt) self.handle_collisions(displacement) self.animation.update_state(velocity, input)
undefined

Example 2: VR Experience Development

示例2:VR体验开发

Scenario: Creating an immersive VR experience for Oculus/Meta Quest.
VR Implementation:
  1. Locomotion: Teleportation and smooth movement options
  2. Interaction: Hand tracking with gesture recognition
  3. Optimization: Single-pass stereo rendering
  4. Comfort: Comfort mode options for sensitive users
Key Considerations:
  • 72Hz minimum frame rate for comfort
  • Motion sickness avoidance in design
  • Hand physics for realistic interaction
  • Battery optimization for standalone headsets
场景: 为Oculus/Meta Quest打造沉浸式VR体验。
VR实现:
  1. 移动方式: 支持传送与平滑移动选项
  2. 交互: 手部追踪与手势识别
  3. 优化: 单通道立体渲染
  4. 舒适度: 为敏感用户提供舒适模式选项
核心注意事项:
  • 最低72Hz帧率以保证舒适度
  • 设计中避免引发晕动症
  • 手部物理以实现真实交互
  • 针对独立头显的电池优化

Example 3: Multiplayer Battle Royale

示例3:多人大逃杀游戏

Scenario: Developing a competitive multiplayer game with 100 players.
Multiplayer Architecture:
  1. Networking: Client-side prediction with server reconciliation
  2. Lag Compensation: Interpolation and extrapolation techniques
  3. Anti-Cheat: Server-side validation, cheat detection
  4. Matchmaking: Skill-based matchmaking with queue optimization
场景: 开发支持100名玩家的竞技类多人游戏。
多人架构:
  1. 网络: 客户端预测与服务器 reconciliation
  2. 延迟补偿: 插值与外推技术
  3. 反作弊: 服务器端验证、作弊检测
  4. 匹配: 基于技能的匹配与队列优化

Best Practices

最佳实践

Game Development

游戏开发

  • Core Loop First: Prototype and refine the core gameplay loop
  • Modular Architecture: Decouple systems for maintainability
  • Performance Budgeting: Define and monitor performance targets
  • Data-Driven Design: Use configuration files for game balance
  • Version Control: Handle large binary assets appropriately
  • 先做核心循环: 原型制作并打磨核心游戏玩法循环
  • 模块化架构: 解耦系统以提升可维护性
  • 性能预算: 定义并监控性能指标
  • 数据驱动设计: 使用配置文件调整游戏平衡性
  • 版本控制: 正确管理大型二进制资源

Physics and Movement

物理与移动

  • Determinism: Ensure consistent physics across networked games
  • Collision Detection: Optimize for minimal false positives
  • Character Controllers: Separate physics from character logic
  • Ragdoll Physics: Use for death animations and interaction
  • Performance: Profile physics update time, optimize as needed
  • 确定性: 确保联网游戏中物理表现一致
  • 碰撞检测: 优化以减少误判
  • 角色控制器: 将物理与角色逻辑分离
  • 布娃娃物理: 用于死亡动画与交互
  • 性能: 分析物理更新时间并按需优化

Graphics and Rendering

图形与渲染

  • Batching: Group draw calls for GPU efficiency
  • Level of Detail: Implement LOD for models and textures
  • Shaders: Optimize shader complexity, use shared materials
  • Lighting: Balance quality and performance, use baked lighting
  • Post-Processing: Apply selectively, profile GPU impact
  • 批处理: 合并绘制调用以提升GPU效率
  • 细节层次(LOD): 为模型与纹理实现LOD
  • 着色器: 优化着色器复杂度,使用共享材质
  • 光照: 平衡画质与性能,使用烘焙光照
  • 后处理: 选择性应用,分析GPU负载

Audio Implementation

音频实现

  • Spatial Audio: 3D positioning for immersion
  • Adaptive Music: Dynamic soundtrack based on gameplay
  • Performance: Stream large audio files, pool sound effects
  • Compression: Use appropriate audio compression formats
  • Accessibility: Provide audio cues as alternatives to visual feedback
  • 空间音频: 3D定位以增强沉浸感
  • 自适应音乐: 根据游戏玩法动态调整配乐
  • 性能: 流式传输大型音频文件,复用音效资源
  • 压缩: 使用合适的音频压缩格式
  • 无障碍: 提供音频提示作为视觉反馈的替代方案

Testing and Quality

测试与质量

  • Playtesting: Regular playtesting sessions for feedback
  • Performance Profiling: Monitor frame rate, memory, load times
  • Platform Testing: Test on target hardware, not just dev machines
  • Accessibility: Implement accessibility features from start
  • Localization: Plan for international markets early
  • 玩法测试: 定期开展玩法测试以收集反馈
  • 性能分析: 监控帧率、内存、加载时间
  • 平台测试: 在目标硬件上测试,而非仅开发机
  • 无障碍: 从项目初期就实现无障碍功能
  • 本地化: 尽早规划面向国际市场的本地化