◉ANTIGRAVITY LABJP
Articles/App Development
▣ App Development/2026-04-28Advanced

Antigravity × Unreal Engine 5 Plugin Production Guide — Designing Reusable Game Systems with AI for Multiple Titles

A production-grade guide to building UE5 plugins with Antigravity. Covers module design, build configuration, AI-friendly code separation, and distribution patterns for reusing one plugin across multiple titles.

antigravity477unreal-engine-5ue5plugingame-devcppproduction71

✦ Premium Article

I stopped halfway through rebuilding the code for this piece one evening. The save container in the first version was a UCLASS() declared inside a .cpp file, which Unreal Header Tool never sees. The CI example set $env:UE5_ROOT in one step and read it in the next, where it no longer exists. Both were shapes the agent had produced and I had pasted without asking a compiler. Looking back, I think the suggestions simply looked tidy enough that I skipped the boring part.

If you're starting a second or third UE5 title, you probably want inventory, save, and achievements out of the game module and into a plugin. Where people get stuck is almost always the .Build.cs dependency graph and the Public/Private boundary. Antigravity will happily propose both — but a proposal and a passing build are different things.

Let the agent draft the scaffolding; let my own compiler decide the boundaries. That's the line I settled on while revising this. What follows is a plugin layout that works well with Antigravity, built around three systems, targeting Unreal Engine 5.7–5.8 as of November 2026 (check the official release notes). A few parts I haven't been able to build on real hardware myself, and I say so where that applies.

Why "AI-friendly plugin structure" matters

Antigravity reads AGENTS.md and your file layout to decide what to generate. If you point it at a UE5 project, it tends to treat Source/<GameName>/ as one big module. Plugin headers under Plugins/ get read as separate context, and the agent often loses track of which symbols are exported and which are not.

The biggest casualty is the Public//Private/ split. UE5 only allows other modules to #include headers under Public/. Ask Antigravity to "write code that adds an item to the inventory" without giving it that boundary, and it will happily reach into a Private/ struct from your game module — which compiles in the plugin but fails to link in the consuming module with unresolved external symbol.

The starting point: split the plugin into an API layer and an implementation layer, and write that split down in an AGENTS.md the agent can read. Whether it raises suggestion quality will vary by project, but at minimum it lets you point at the exact rule a bad diff breaks.

Plugin skeleton: .uplugin and .Build.cs

Start with the file layout. We'll put the plugin at Plugins/CommonGameSystems/:

Plugins/CommonGameSystems/
├── CommonGameSystems.uplugin
└── Source/
    ├── CommonGameSystemsRuntime/
    │   ├── CommonGameSystemsRuntime.Build.cs
    │   ├── Public/
    │   │   ├── Inventory/InventoryComponent.h
    │   │   ├── SaveSystem/GameSaveSubsystem.h
    │   │   └── Achievements/AchievementSubsystem.h
    │   └── Private/
    │       ├── CommonGameSystemsRuntime.cpp
    │       ├── Inventory/InventoryComponent.cpp
    │       ├── SaveSystem/GameSaveSubsystem.cpp
    │       └── Achievements/AchievementSubsystem.cpp
    └── CommonGameSystemsEditor/
        ├── CommonGameSystemsEditor.Build.cs
        ├── Public/
        └── Private/

The split between Runtime and Editor is non-negotiable for shipping. Editor modules are stripped from packaged builds, so they're the right home for editor-only tools and asset actions. Skip this split early on and you'll spend a frustrating afternoon hunting down "missing Slate" or "unresolved UnrealEd" errors at packaging time.

Here's the CommonGameSystems.uplugin:

{
  "FileVersion": 3,
  "Version": 1,
  "VersionName": "1.0.0",
  "FriendlyName": "Common Game Systems",
  "Description": "Reusable runtime systems (inventory, save, achievements) for UE5 indie titles.",
  "Category": "Gameplay",
  "CreatedBy": "Your Studio",
  "EnabledByDefault": true,
  "CanContainContent": true,
  "Installed": false,
  "Modules": [
    {
      "Name": "CommonGameSystemsRuntime",
      "Type": "Runtime",
      "LoadingPhase": "Default"
    },
    {
      "Name": "CommonGameSystemsEditor",
      "Type": "Editor",
      "LoadingPhase": "PostEngineInit"
    }
  ]
}

Keep LoadingPhase at Default unless you have a written reason. Earlier phases such as PreDefault or PostConfigInit run your module's StartupModule() before engine initialization finishes, so code there that touches UAssetManager and friends will fail. Gameplay subsystems (UGameInstanceSubsystem) are created when the UGameInstance initializes anyway, so loading the module earlier buys you nothing.

The .Build.cs is the file Antigravity gets wrong most often. Keep this template at the top of the file so you can spot incorrect dependency additions in your diff:

// Copyright (c) Your Studio. All Rights Reserved.
using UnrealBuildTool;
 
public class CommonGameSystemsRuntime : ModuleRules
{
    public CommonGameSystemsRuntime(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
        bUseUnity = false; // Faster per-file builds during plugin dev — turn on later
 
        // UBT adds Public/ and Private/ to the include paths automatically,
        // so don't add PublicIncludePaths / PrivateIncludePaths by hand
 
        PublicDependencyModuleNames.AddRange(new[]
        {
            "Core", "CoreUObject", "Engine",
            "GameplayTags",          // identify item types via tags
            "DeveloperSettings",     // data-driven settings
        });
 
        PrivateDependencyModuleNames.AddRange(new[]
        {
            "OnlineSubsystem",       // achievements (enable OnlineSubsystem in the .uplugin too)
        });
    }
}

I removed the two PublicIncludePaths lines from the first version. UBT already adds the module's Public/ and Private/ folders, and hand-written relative paths are an easy place to introduce a typo. If the agent adds them back, just delete them in the diff.

bUseUnity = false is a stylistic choice for production, but during plugin development it's a quality-of-life win. Single-file builds make it much easier to localize the file that broke when the AI's last suggestion didn't compile. Flip it back to true once the plugin stabilizes.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Structure your UE5 plugin's Public/Private boundary so Antigravity stops generating broken Build.cs files and unresolved external symbols
✦Walk away with three working systems — inventory, save, and achievements — complete with .uplugin and .Build.cs ready to drop into your project
✦Design version management, build isolation, and module dependency rules that hold up when you reuse a single plugin across two, three, or more shipped titles
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

▣ App Dev2026-05-03
Building Idempotency Keys and Dedupe Stores in TypeScript with Antigravity
A production guide to designing idempotency keys and dedupe stores in TypeScript with Antigravity — covering Stripe webhook retries, Temporal replays, and the Cloudflare KV / Redis / Postgres trade-offs you actually need to choose between.
▣ App Dev2026-05-01
Zero-Downtime Database Migrations with Antigravity: The Expand-Contract Pattern in Production
Run PostgreSQL type swaps, column renames, and table splits without stopping traffic: the Expand-Contract pattern with lock_timeout, chunked backfills, and primary-key swaps, checked with Antigravity's AI assistance.
▣ App Dev2026-04-26
Antigravity × Cloudflare Edge SaaS Architecture Guide: Production Patterns with D1, Workers, R2, and Workers AI
A complete production guide for building edge SaaS with Antigravity + Cloudflare D1, Workers, R2, and Workers AI. Covers real pitfalls including N+1 queries, CPU limits, and cost management.