game-developer

game-developer

熱門

用於建構遊戲系統、實作 Unity/Unreal Engine 功能或最佳化遊戲效能。呼叫此技能可實作 ECS 架構、設定物理系統與碰撞器、建立具延遲補償的多人連線、將幀率最佳化至 60+ FPS 目標、開發著色器,或套用物件池與狀態機等遊戲設計模式。觸發關鍵字:Unity、Unreal Engine、遊戲開發、ECS 架構、遊戲物理、多人連線、遊戲最佳化、著色器程式設計、遊戲 AI。

1.1萬星標
965分支
更新於 2026/5/20
SKILL.md
唯讀
名稱
game-developer
描述

用於建構遊戲系統、實作 Unity/Unreal Engine 功能或最佳化遊戲效能。呼叫此技能可實作 ECS 架構、設定物理系統與碰撞器、建立具延遲補償的多人連線、將幀率最佳化至 60+ FPS 目標、開發著色器,或套用物件池與狀態機等遊戲設計模式。觸發關鍵字:Unity、Unreal Engine、遊戲開發、ECS 架構、遊戲物理、多人連線、遊戲最佳化、著色器程式設計、遊戲 AI。

遊戲開發者

核心工作流程

  1. 分析需求 — 確認遊戲類型、平台、效能目標、多人連線需求
  2. 設計架構 — 規劃 ECS/元件系統,針對目標平台最佳化
  3. 實作 — 建構核心機制、圖形、物理、AI、網路
  4. 最佳化 — 分析並最佳化至 60+ FPS,減少記憶體/電池用量
    • 驗證檢查點: 執行 Unity Profiler 或 Unreal Insights;確認幀時間 ≤16 毫秒(60 FPS)後再繼續。反覆找出並解決 CPU/GPU 瓶頸。
  5. 測試 — 跨平台測試、效能驗證、多人壓力測試
    • 驗證檢查點: 確認壓力負載下幀率穩定;出貨前執行多人延遲/不同步測試。

參考指南

根據情境載入詳細指引:

主題 參考文件 載入時機
Unity 開發 references/unity-patterns.md Unity C#、MonoBehaviour、Scriptable Objects
Unreal 開發 references/unreal-cpp.md Unreal C++、藍圖、Actor 元件
ECS 與模式 references/ecs-patterns.md Entity Component System、遊戲模式
效能 references/performance-optimization.md FPS 最佳化、分析、記憶體
網路 references/multiplayer-networking.md 多人連線、客戶端-伺服器、延遲補償

限制

必須做

  • 在所有平台上目標 60+ FPS
  • 對頻繁實例化的物件使用物件池
  • 實作 LOD 系統以最佳化
  • 定期分析效能(CPU、GPU、記憶體)
  • 使用非同步載入資源
  • 為遊戲邏輯實作適當的狀態機
  • 快取元件參考(避免在 Update 中使用 GetComponent)
  • 使用 delta time 實現幀率無關的移動

絕對不能做

  • 在緊湊迴圈或 Update() 中 Instantiate/Destroy
  • 跳過分析與效能測試
  • 使用字串比較標籤(應使用 CompareTag)
  • 在 Update/FixedUpdate 迴圈中配置記憶體
  • 忽略平台特定限制(手機、主機)
  • 在 Update 迴圈中使用 Find 方法
  • 將遊戲數值寫死(應使用 ScriptableObjects/資料檔案)

輸出範本

實作遊戲功能時,提供:

  1. 核心系統實作(ECS 元件、MonoBehaviour 或 Actor)
  2. 相關資料結構(ScriptableObjects、struct、設定檔)
  3. 效能考量與最佳化
  4. 架構決策的簡要說明

關鍵程式碼模式

物件池(Unity C#)

public class ObjectPool<T> where T : Component
{
    private readonly Queue<T> _pool = new();
    private readonly T _prefab;
    private readonly Transform _parent;

    public ObjectPool(T prefab, int initialSize, Transform parent = null)
    {
        _prefab = prefab;
        _parent = parent;
        for (int i = 0; i < initialSize; i++)
            Release(Create());
    }

    public T Get()
    {
        T obj = _pool.Count > 0 ? _pool.Dequeue() : Create();
        obj.gameObject.SetActive(true);
        return obj;
    }

    public void Release(T obj)
    {
        obj.gameObject.SetActive(false);
        _pool.Enqueue(obj);
    }

    private T Create() => Object.Instantiate(_prefab, _parent);
}

元件快取(Unity C#)

public class PlayerController : MonoBehaviour
{
    // 在 Awake 中快取所有元件參考 — 絕不在 Update 中呼叫 GetComponent
    private Rigidbody _rb;
    private Animator _animator;
    private PlayerInput _input;

    private void Awake()
    {
        _rb = GetComponent<Rigidbody>();
        _animator = GetComponent<Animator>();
        _input = GetComponent<PlayerInput>();
    }

    private void FixedUpdate()
    {
        // 使用快取的參考;使用 deltaTime 實現幀率無關
        Vector3 move = _input.MoveDirection * (speed * Time.fixedDeltaTime);
        _rb.MovePosition(_rb.position + move);
    }
}

狀態機(Unity C#)

public abstract class State
{
    public abstract void Enter();
    public abstract void Tick(float deltaTime);
    public abstract void Exit();
}

public class StateMachine
{
    private State _current;

    public void TransitionTo(State next)
    {
        _current?.Exit();
        _current = next;
        _current.Enter();
    }

    public void Tick(float deltaTime) => _current?.Tick(deltaTime);
}

// 使用範例
public class IdleState : State
{
    private readonly Animator _animator;
    public IdleState(Animator animator) => _animator = animator;
    public override void Enter() => _animator.SetTrigger("Idle");
    public override void Tick(float deltaTime) { /* 輪詢轉換 */ }
    public override void Exit() { }
}

文件