Unreal Engine C++ code generation
Answers for every CodeForge workflow.
CodeForge helps Unreal Engine teams define native C++ classes, structs, enums, interfaces, properties, functions, delegates, RPCs, and replication setup in a visual editor, then generate Unreal-compatible source files.
Basics
What CodeForge is, what it creates, and who gets the most from it.
What is CodeForge?
An Unreal Engine 5.7 editor plugin that generates native C++ types from a definition. You describe the type in a node graph (or a JSON file): parent, members, specifiers, replication, function bodies. CodeForge validates it against UnrealHeaderTool and compiler rules and writes the .h/.cpp pair into your module.
What can it generate?
ClassesInterfacesStructsEnums
Classes can derive from 20 built-in parents (Actor, Pawn, Character, components, GameMode, GameState, PlayerController, PlayerState, HUD, Object, data assets, SaveGame, GameInstance, the four subsystem kinds, Blueprint Function Library) or any C++ parent you name. Members cover properties with every common specifier, functions (callable, pure, native and implementable events, static, Exec, CallInEditor, overrides), RPCs, delegates and replication. Structs can derive from FTableRowBase, and enums can be bitflags.
Does it write gameplay logic too?
It writes whatever bodies you give it. Each function, RPC, OnRep_ handler, constructor and interface override has a body field, and the definition is the source of truth for the whole file. The Arena sample is a complete game written this way. If you leave a body empty you get a // TODO stub.
Does generated code depend on CodeForge?
No. Output is plain Unreal C++ with no CodeForge headers or modules. You can remove the plugin and keep the code.
What does "CodeForge Blueprint" mean?
It is the name of the asset that stores a definition. It is not a gameplay Blueprint and doesn't run in your game.
Installation And Setup
Getting a project ready to generate C++.
How do I install it?
Install from Fab, or copy the plugin folder to <YourProject>/Plugins/CodeForge. Regenerate project files, build, and confirm under Edit → Plugins → Editor.
My project is Blueprint-only. Can I use it?
Add a C++ module first (Tools → New C++ Class, any class, then build once). CodeForge writes into existing modules and doesn't create modules.
Which modules can receive generated code?
The game modules declared in your .uproject, and the modules of your project plugins, including nested Game Feature plugins. The wizard lists them all. Headers go to the module's Public/ folder and sources to Private/, plus an optional sub-folder.
Which engine versions and platforms?
Unreal Engine 5.7. The plugin supports Windows and Linux editors. Generated code is ordinary engine code and builds for any platform your project targets.
Daily Workflow
Creating, editing and checking definitions.
How do I start a new type?
Content Browser → Add → CodeForge → CodeForge Blueprint. The wizard offers 23 archetypes (Actor, Replicated Actor, Character, components, game framework classes, subsystems, function library, interface, data asset, save game, struct, Data Table row, enum, bitflags enum), a module, a sub-folder and optional starter members.
How do I see what will be written?
The Code Preview panel shows the exact header and source, syntax-coloured, and a status chip: Not generated yet, Up to date, Changed, Hand-written file in the way, Module not found or Fix errors.
What does validation catch?
What UHT or the compiler would reject, before you build: invalid or reserved names, duplicate members, conflicting specifiers, BlueprintPure without outputs, virtual events, non-static library functions, interface rules, RepNotify without replication, replicated members on non-replicated classes, RPC parameter defaults, overrides marked UFUNCTION, parameters that shadow class, parent or interface members, enum values out of range and non-power-of-two bitflags. Errors block generation and warnings don't.
Can CodeForge fix problems for me?
Several findings have an automatic fix: b prefixes for bools, enabling replication on a RepNotify property or on the class, removing replication flags from struct members, and dropping UFUNCTION from overrides. Right-click the node and choose Fix: ..., or click Fix All. Both are undoable.
Does undo work?
Yes, for graph edits, Details edits and fixes. Undo and redo also refresh validation and the preview.
Code Generation
Writing files, reloading, and keeping hand-written code safe.
Will CodeForge overwrite my hand-written files?
Not silently. Generated files start with // Generated by CodeForge - DO NOT EDIT. If a file with the target name lacks that marker, the editor lists it and asks before replacing it, and the commandlet refuses unless you pass -Overwrite.
Can I edit a generated file?
Edit the definition instead. The next generation replaces the file. Bodies for functions, RPCs, OnRep_, the constructor and interface overrides all live in the definition, so nothing has to be hand-edited. To take a file over by hand, delete the marker line and CodeForge will treat it as hand-written from then on.
Do I need to restart the editor after generating?
If only function bodies changed, Live Coding can patch the running editor, automatically if Auto Live Coding On Behavioral Change is on. New types and changed UPROPERTY/UFUNCTION declarations need a rebuild; CodeForge offers Live Coding, but closing the editor and building is the reliable path.
Does it update my IDE project?
When generation creates new files, CodeForge refreshes the IDE project files (setting: Regenerate Project Files On New Files). Open C++ in the toolbar or the context menu opens the generated files.
How do types that reference each other generate?
Batch generation (folders, multi-selection, the commandlet) runs enums, then structs, then interfaces, then classes. A class implementing a CodeForge interface gets the interface include and every override automatically. For other types, set the property's Include Path or add the header to Source Includes.
Is the output deterministic?
Yes. The same definition always produces the same bytes: LF line endings, four-space indentation, no trailing whitespace, one final newline. That makes generated code diff cleanly and lets CI verify it is up to date.
Lift to C++
Turning an existing Blueprint into a C++ base class.
What does Lift to C++ do?
It generates a C++ parent class for a Blueprint that holds the Blueprint's variables, functions, event dispatchers and custom events, plus C++ versions of the Blueprint structs and enums they use. After you build, Complete Lift reparents the Blueprint onto that class and redirects every reference: in the Blueprint, in other Blueprints, and in values saved in maps. Your graphs keep working, and C++ can now read the variables, bind the dispatchers and fire the events.
Does it convert my Blueprint logic to C++?
No. It moves the Blueprint's interface: data, function signatures, dispatchers, events, structs and enums. Each function becomes a C++ declaration with an empty _Implementation stub, and the Blueprint's graph keeps running as its override. Port the logic into the stub when you're ready, then delete the override.
Is it safe to run on a real project?
Complete Lift checks its own work before it keeps it. It confirms that everything compiles, that no pin link was lost, that no Blueprint still uses a replaced struct, and that class defaults and per-instance values in maps are unchanged. If any check fails it undoes itself automatically. A successful lift is one undo step (Ctrl+Z, values included), and the affected assets are backed up for Restore Pre-Lift Backup, which also works after a restart. Commit or back up your project anyway, as with any refactor.
Why do I have to build and restart in the middle?
The Blueprint can only be reparented onto a class that exists, and a new UCLASS needs a real build. CodeForge prepares everything, then offers Complete Now the next time the editor starts.
What stays in the Blueprint?
The dialog lists each member that stays and why. That covers:
- names that aren't C++ identifiers;
- variables typed with Blueprint classes or bitmask Blueprint enums;
- RepNotify, Call In Editor and thread-safe functions, and input defaults C++ can't hold;
- RepNotify, Config and Field Notify variables;
- replicated and Call In Editor events;
- anything whose C++ wouldn't compile, such as a parameter named like a variable.
You can also untick members you want to keep.
What happens to the Blueprint struct?
It is replaced by the generated C++ struct in every Blueprint that uses it, including Make and Break nodes, parameters and defaults, and the values are carried over. The Blueprint struct asset itself stays in place. If anything else still uses it, such as a DataTable, CodeForge lists those assets.
JSON & Automation
Definitions as files, headless generation and scripting.
How do two people change the same type without a binary merge conflict?
Every generated type keeps its definition as text next to its header (Turret.codeforge.json beside Turret.h). Merge that file like any source file, then regenerate from it with -run=CodeForge -Schema=Source/MyGame -Generate, or update the assets with -Import=Source/MyGame. Each file holds one type and CodeForge writes it deterministically, so a one-field change is a one-line diff.
Can definitions live in source control as text?
Yes. Export assets to a .codeforge.json file (right-click → Export Schema...) and import it back with Tools → CodeForge → Import Schema.... Keys are the C++ field names and defaults are omitted, so the files stay short and review well. Schema/codeforge.schema.json gives VS Code and Rider completion and validation.
Can I generate without opening the editor?
UnrealEditor-Cmd MyGame.uproject -run=CodeForge -Schema=Design/Game.codeforge.json -Generate -unattended -nullrhi. Other options: -Import/-Dest, -Source=/Game/Path, -Validate, -Export, -ProjectDir, -Overwrite. The exit code is 1 on any error, so CI fails properly.
Is there a Python API?
unreal.CodeForgeEditorLibrary: generate_code, generate_folder, preview_code, validate_definition, apply_auto_fixes, import_schema, export_schema, find_definitions. Operations return a result with success, message and files. The same functions are available to Editor Utility Blueprints.
Templates And Customization
Changing what the generated files look like.
Can I change the output format?
Yes. Set Custom Template Path in the plugin settings and copy only the .cft files you want to change from Plugins/CodeForge/Content/Templates. Lookup is per file, so everything else keeps using the built-ins and picks up CodeForge updates.
What can I safely change in a template?
Banners, includes (a precompiled header, for example), ordering and spacing. Keep the // Generated by CodeForge - DO NOT EDIT marker in copyright_header.cft, because CodeForge uses it to recognise its own files. Declarations arrive fully formed, so arrange them rather than rebuild them.
Can I change node colours and fonts?
Yes: Project Settings → Plugins → CodeForge has per-node colours, brand colours, body brightness and font sizes.
Troubleshooting
The usual suspects and their fixes.
"Could not find module 'X' in project"
The definition targets a module that isn't in this project, usually after importing a JSON file from elsewhere. Set Module Target to one of your modules. Import Sample Pack retargets automatically.
The build fails with an unknown type in a generated header.
Add the header for that type to the property's Include Path or to the function's include, or add it under Source Includes when only the .cpp needs it.
The new class doesn't show up after Generate.
New types need a rebuild. Live Coding can't always register a new class in a running editor. Close the editor, build, and reopen.
Validation warns about shadowing.
A parameter has the same name as a class, parent or interface member, for example Instigator on an Actor. MSVC reports that as C4458, which Unreal builds treat as an error. Rename the parameter.
Team Use And Source Control
Working with CodeForge in a shared repository.
What should we commit?
Commit the definitions (assets and/or .codeforge.json files) and the generated sources. Teammates without CodeForge can still build the project. The JSON form makes reviews easy because a definition change and its generated diff sit side by side.
How do we stop generated code drifting from the definitions?
Run the commandlet in CI with -Generate, then git diff --exit-code -- Source. Generation is deterministic, so any diff means someone edited a generated file or forgot to regenerate.
Arena Sample
A complete game built only from generated code.
What is the Arena sample?
A small target-range game: turrets, colour-coded targets, pickups, a score HUD, a save slot for the best score and console cheats. All 16 gameplay types, including a replicated component with delegates and an RPC, an interface, a subsystem, a Data Table row and a bitflags enum, come from one definition file, Samples/Arena/Arena.codeforge.json.
How do I try it in my project?
Tools → CodeForge → Import Sample Pack, then select /Game/CodeForgeSamples/Arena, choose Generate C++ and build. Definitions are retargeted to your first game module. A script for laying out the demo map ships in the CodeForge sample project (Scripts/BuildArenaDemo.py).
Where did the RPG Starter Kit go?
It was replaced in 0.3.0. The old kit's assets didn't round-trip through the current generator; Arena does, it compiles in the test suite, and an automated test plays it.
Fab And Distribution
Getting the plugin and shipping projects that use it.
Do I need to ship CodeForge with my game?
No. Generated code doesn't depend on CodeForge, so you can disable or remove the plugin and the game still builds. While the plugin is enabled, its editor module is left out of packaged builds; only the small runtime module that defines the definition asset type is packaged.
Where is the official listing?
On Fab: CodeForge.
Support And Community
Where to ask, and what to include.
Where do I get help?
Ask on the GregOrigin Discord. Include the engine version, the CodeForge version, the definition (export it to JSON) and the build or validation output.
Updates And Maintenance
Moving between CodeForge versions.
What's new in 0.5.0?
Lift to C++ (Blueprint to C++ base class: variables, functions, dispatchers, events, structs and enums), definition files next to the generated code for review and merging, and case-sensitive keyword checks. See CHANGELOG.md.
What changed in 0.3.0?
Interfaces, delegates, many new parents and options, the wizard, JSON import/export with a JSON Schema, the commandlet, the Python library, menu actions, the syntax-coloured preview with file status, auto-fix, plugin-module targets, deterministic output, and many correctness fixes. See CHANGELOG.md.
Will my existing assets still open?
Yes. Older class nodes get the new Delegates pin when opened. Regenerate after updating: output formatting changed in 0.3.0, so expect a one-time diff in generated files.
I have custom templates from an older version.
Compare them with the new built-ins. Values were renamed and added (for example access-level member lists and HeaderIncludePath), and because lookup is now per file you can delete any override you no longer need.
Start with the asset, preview the output, then compile with confidence.
Use Fab for the official CodeForge listing, the manual for detailed workflows, and Discord for support, bug reports and feature requests.