[!IMPORTANT] The way Cog integrates in your project has changed. If you update Cog, please read the integration guide.
Cog is a set of debug tools for Unreal Engine built on top of Dear ImGui
Cog provides:
General Info:
[F1]
key or use the Cog.ToggleInput
console command to open the ImGui Main Menu.Engine/Selection
window or widget.Window/Widgets
menu.Cog comes with the following windows:
Displays the gameplay abilities of the selected actor.
Displays the state of Input Action.
https://github.com/user-attachments/assets/2497900e-d2d9-4af9-abef-44f7f31c2726
Displays the gameplay attributes of the selected actor.
Displays the behavior tree of the selected actor.
Displays the blackboard of the selected actor.
Display the build information such as the build version, changelist, date, target, and so on.
Used to apply cheats to the selected actor.
[CTRL]
Apply the cheat to the controlled actor[ALT]
Apply the cheat to the allies of the selected actor[SHIFT]
Apply the cheat to the enemies of the selected actorUsed to test collision queries
Used to inspect collisions in the world
Used to configure the command bindings.
Saved/Config/WindowEditor/Input.ini
(in editor).Used as a replacement of the Unreal console command.
Used to tweak how the debug display is drawn.
Displays the gameplay effects of the selected actor.
Display the state of the gamepad
https://github.com/user-attachments/assets/56edc823-7130-4cfe-9af9-1c565f7286b9
Used to inspect and modify an Object properties
Can be used to load specific levels
Can be used to activate and deactivate log categories
Gather various values sent by the selected actor and compute their rate per second. This is typically used to compute the damage dealt or received per second.
// Adding a metric
FCogDebugMetric::AddMetric(this, "Damage Dealt", MitigatedDamage, UnmitigatedDamage, false);
Used to configure the network emulation
Handle connections to a NetImgui server.
The following image shows the editor running along a dedicated server. The NetImgui server displays the dedicated server imgui windows.
This can be used to debug the state of the game server. For example the behavior trees are only available on the game server.
Use to display and configure notifications
COG_NOTIFY
, COG_NOTIFY_WARNING
, or COG_NOTIFY_ERROR
.Display the output log based on each log categories verbosity.
Plots values and events overtime. When applicable, only the values and events of the selected actor are displayed.
// Plotting a value
FCogDebug::Plot(this, "Speed", Velocity.Length());
// Starting an event
FCogDebug::StartEvent(this, "Effects", GameplayEffectSpec.Def->GetFName(), GameplayEffectSpec.GetDuration() == 0.0f)
.AddParam("Name", AbilitySystemComponent->CleanupName(GetNameSafe(GameplayEffectSpec.Def)))
.AddParam("Effect Instigator", GetNameSafe(GameplayEffectSpec.GetEffectContext().GetInstigator()))
.AddParam("Effect Level", GameplayEffectSpec.GetLevel())
.AddParam("Effect Duration", GameplayEffectSpec.GetDuration());
// Stopping an event
FCogDebug::StopEvent(this, "Effects", RemovedGameplayEffect.Spec.Def->GetFName());
Displays attributes of the selected actor as pools.
Used to configure the rendering quality.
Used to select an actor either by picking an actor in the world or by selecting an actor in the actor list.
Configure the settings of Cog.
[Ctrl][MouseWheel]
to change the DPI.Display the bone hierarchy and the skeleton debug draw of the selected actor if it has a Skeletal Mesh.
[Ctrl]
key to toggle the bone debug draw recursively.Used to spawn new actors in the world. The spawn list can be configured in a Data Asset.
Displays engine stats such as FPS, Ping, Packet Loss.
Displays the gameplay tags of the selected actor.
Used to change the game global timescale.
Used to read and set the selected actor transform.
Used to apply tweaks to all the spawned actors
Cog provides C++ and Blueprint functions to log and debug draw within Log Categories.
Log and debug draw functions can be filtered by the selected actor.
You must have Unreal 5.5 or greater and Visual Studio to launch the sample
Cog.uproject
and click Generate Visual Studio project files
DebugGame Editor
or Development Editor
solution configurationCog
is set as the startup project[F5]
[Alt+P]
[F1]
key or use the Cog.ToggleInput
console command to open the Imgui Main Menu.[!IMPORTANT] The way Cog integrates in your project has changed. If you didn't modify Cog sources, you should remove all your existing Cog source files before updating. If you did modify Cog sources and still have a
CogWindow
folder, consider deleting it before updating. Previously Cog was integrated from your project GameState class. Now it is integrated from UWorldSubsystem in your project as described in the integration guide below.
The Cog repository has the following structure:
CogSample
- A Sample that demonstrate various Cog functionalities. The project was saved in Unreal 5.5Plugins/CogAbility
- ImGui windows for the Gameplay Ability System (Abilities, Effects, Tags, ...)Plugins/CogAI
- ImGui windows for AI (Behavior Tree, Blackboard)Plugins/CogInput
- ImGui windows for the Enhanced Input library (Input action, Gamepad)Plugins/Cog
- The main Cog plugin which contains the following modules
Cog
- Cog Subsystem (Manage windows, menu, settings, layout, ...)CogCommon
- Interfaces implemented by your project actor classes which cannot be excluded from a shipping buildCogDebug
- Debug functionalities (Log, Debug Draw, Plot, Metric, ...)CogEngine
- ImGui windows for the core unreal engine functionalities (Log, Stats, Time, Collisions, Skeleton, ...)CogImGui
- Cog own integration of Imgui for Unreal, inspired by UnrealImGuiPlugins/CogAll
- Only contains a utility function to easily add all the built-in windows from all the Cog plugins. Useful for projects that do not need to exclude some plugins.Plugins/CogCommonUI
- Contains an implementation of CommonUIActionRouterBase to let the Cog shortcuts work while in a CommonUI menu. Only use this plugin if you use CommonUI.Cog has multiple plugins to ease the integration for projects that do not use the Ability System Component
or Enhanced Input
. For the next steps, it is assumed all the plugins are used.
// CogSample.Build.cs
using UnrealBuildTool;
public class CogSample : ModuleRules
{
public CogSample(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[]
{
"CogCommon", // CogCommon is required on all target configuration
"AIModule",
"Core",
"CoreUObject",
"Engine",
"EnhancedInput",
"GameplayTasks",
"GameplayAbilities",
"GameplayTags",
"InputCore",
"NetCore",
});
// Other Cog plugins can be added only for specific target configuration
if (Target.Configuration != UnrealTargetConfiguration.Shipping)
{
PublicDependencyModuleNames.AddRange(new string[]
{
"Cog",
"CogAbility",
"CogAI",
"CogAll",
"CogDebug",
"CogEngine",
"CogImgui",
"CogInput",
});
}
}
}
CogSampleConfigurationSubsystem
as a template.CogSampleConfigurationSubsystem.h
#pragma once
#include "Subsystems/WorldSubsystem.h"
#include "CogSampleConfigurationSubsystem.generated.h"
UCLASS()
class UCogSampleConfigurationSubsystem : public UWorldSubsystem
{
GENERATED_BODY()
public:
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
virtual void PostInitialize() override;
private:
UPROPERTY()
TWeakObjectPtr<USubsystem> CogSubsystem;
};
CogSampleConfigurationSubsystem.cpp
#include "CogSampleConfigurationSubsystem.h"
#include "CogCommon.h"
#if ENABLE_COG
#include "CogAll.h"
#include "CogSampleWindow_Team.h"
#include "CogSubsystem.h"
#endif
bool UCogSampleConfigurationSubsystem::ShouldCreateSubsystem(UObject* Outer) const
{
if (Super::ShouldCreateSubsystem(Outer) == false)
{ return false; }
#if ENABLE_COG
return true;
#else
return false;
#endif
}
void UCogSampleConfigurationSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);
#if ENABLE_COG
CogSubsystem = Collection.InitializeDependency<UCogSubsystem>();
#endif
}
void UCogSampleConfigurationSubsystem::PostInitialize()
{
Super::PostInitialize();
#if ENABLE_COG
UCogSubsystem* CogSubsystemPtr = Cast<UCogSubsystem>(CogSubsystem.Get());
if (IsValid(CogSubsystemPtr) == false)
{ return; }
// Add all the built-in windows. You can copy and paste this function code to organize the main menu differently.
Cog::AddAllWindows(*CogSubsystemPtr);
// Add a custom window
CogSubsystemPtr->AddWindow<FCogSampleWindow_Team>("Gameplay.Team");
#endif
}
[!NOTE] The reason you need to manually add this code is because you can customize which windows are displayed in the main menu, and because all Cog code appart from the
CogCommon
module is stripped inShipping
build.
// CogSampleCharacter.h
UCLASS(config=Game)
class ACogSampleCharacter : public ACharacter
, public ICogCommonDebugFilteredActorInterface
, public ICogCommonAllegianceActorInterface
// CogSamplePlayerController.h
UCLASS(config=Game)
class ACogSamplePlayerController
: public APlayerController
, public ICogCommonPossessorInterface
Cog integrated in Lyra: