AgentSkillsCN

unreal-engine

Unreal Engine 5开发的最佳实践,涵盖蓝图与C++的平衡、网络通信以及构建规范等关键领域。

SKILL.md
--- frontmatter
name: unreal-engine
description: Best practices for Unreal Engine 5 development, including Blueprint/C++ balance, Networking, and Build standards.

Unreal Engine Development Standards

1. Engine Version

  • Target Version: 5.4.2 (Strict Lock).
  • Update Policy: Do not upgrade unless explicitly instructed.

2. Directory Structure

  • Content/: Store all assets here. Organizing by type (Materials, Meshes, Blueprints) is preferred over organizing by feature.
    • Content/Blueprints/
    • Content/Materials/
    • Content/Maps/
  • Source/: C++ source code.
    • Source/SignalBastion/ implies the primary game module.

3. Blueprint vs. C++ Strategy (Hybrid)

  • C++:
    • Core Systems (Inventory, Health, Networking logic).
    • Base Classes (e.g., ABaseCharacter, ABaseBuilding).
    • Complex Math or heavy loop operations.
  • Blueprint:
    • UI / HUD Logic.
    • Visual Effects & Animation handling.
    • Subclasses for Data tweaking (e.g., BP_GruntEnemy inherits AEnemyBase and sets Health=100).
  • Rule: If a function is called every tick and involves math, move it to C++.

4. Networking (Replication)

  • Authority: The Server is the source of truth.
  • Variable Replication: Use UPROPERTY(Replicated) and GetLifetimeReplicatedProps.
  • RPCs:
    • Server_Function() for client-to-server requests.
    • Client_Function() for server-to-client specific messages.
    • Multicast_Function() for visual events everyone sees (e.g., explosions).
  • Validation: All Server RPCs must have _Validate implementation to prevent cheating.

5. Naming Conventions

  • Classes:
    • A prefix for Actors (AMyActor).
    • U prefix for Objects (UMyObject).
    • E prefix for Enums (EMyEnum).
    • F prefix for Structs (FMyStruct).
    • I prefix for Interfaces (IMyInterface).
  • Variables: bIsDead for booleans.

6. Build & Cook

  • Use UnrealEditor-Cmd.exe for command-line builds if needed.
  • Ensure no "Error/Warning" spam in Output Log.