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.Displays the gameplay abilities of the selected actor.
[]()
Displays the state of Input Action.
Displays the gameplay attributes of the selected actor.
Displays the behavior tree of the selected actor.
Displays the blackboard of the selected actor.
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 a collision query
Used to inspect collisions in the world
Used to configure the command bindings.
Saved/Config/WindowEditor/Input.ini
(in editor).Cog.ToggleInput
Cog.LoadLayout <LayoutIndex>
Cog.ToggleSelectionMode
Used to tweak how the debug display is drawn.
Displays the gameplay effects of the selected actor.
Display the state of the gamepad
Used to inspect and modify an Object properties
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
Display the output log based on each log categories verbosity.
Displays attributes of the selected actor as pools.
Plots values and events overtime. When applicable, only the values and events of the selected actor are displayed.
The following code shows how to plot values and events:
// Plotting a value
FCogDebugPlot::PlotValue(this, "Speed", Velocity.Length());
// Starting an event
FCogDebugPlot::PlotEvent(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
FCogDebugPlot::PlotEventStop(this, "Effects", RemovedGameplayEffect.Spec.Def->GetFName());
Used to configure the rendering quality.
Display the bone hierarchy and the skeleton debug draw of the selected actor if it has a Skeletal Mesh.
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 Windows.
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 time scale.
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.1 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[F1]
key or use the Cog.ToggleInput
console command to open the Imgui Main Menu.The Cog repository has the following structure:
CogSample
- A Sample that demonstrate various Cog functionalities. The project was saved in Unreal 5.1Plugins/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
CogEngine
- ImGui windows for the core unreal engine functionalities (Log, Stats, Time, Collisions, Skeleton, ...)CogWindow
- ImGui window management (Base Window, Layout)CogDebug
- Debug functionalities (Log, Debug Draw, Plot, Metric, ...)CogImGui
- Integration of Imgui for Unreal, inspired by UnrealImGuiCogCommon
- Interfaces implemented by your project actor classes which cannot be excluded from a shipping buildPlugins/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. 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[]
{
"CogAbility",
"CogAI",
"CogAll",
"CogDebug",
"CogEngine",
"CogImgui",
"CogInput",
"CogWindow",
});
}
}
}
- In the class of your choice (in the sample we use the GameState class) add a reference to the CogWindowManager:
```cpp
// ACogSampleGameState.h
#pragma once
#include "CoreMinimal.h"
#include "CogCommon.h"
#include "GameFramework/GameStateBase.h"
#include "CogSampleGameState.generated.h"
class UCogWindowManager;
UCLASS()
class ACogSampleGameState : public AGameStateBase
{
GENERATED_BODY()
[...]
// To make sure it doesn't get garbage collected.
UPROPERTY()
TObjectPtr<UObject> CogWindowManagerRef = nullptr;
#if ENABLE_COG
TObjectPtr<UCogWindowManager> CogWindowManager = nullptr;
#endif //ENABLE_COG
};
// ACogSampleGameState.cpp
void ACogSampleGameState::BeginPlay()
{
Super::BeginPlay();
CogWindowManager = NewObject<UCogWindowManager>(this);
CogWindowManagerRef = CogWindowManager;
// Add all the built-in windows
Cog::AddAllWindows(*CogWindowManager);
// Add a custom window
CogWindowManager->AddWindow<FCogSampleWindow_Team>("Gameplay.Team");
[...]
}
- Tick the CogWindowManager:
```cpp
// ACogSampleGameState.cpp
ACogSampleGameState::ACogSampleGameState(const FObjectInitializer & ObjectInitializer)
: Super(ObjectInitializer)
{
// Enable ticking
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.SetTickFunctionEnable(true);
PrimaryActorTick.bStartWithTickEnabled = true;
[...]
}
void ACogSampleGameState::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
#if ENABLE_COG
CogWindowManager->Tick(DeltaSeconds);
#endif //ENABLE_COG
}
void ACogSamplePlayerController::BeginPlay()
{
Super::BeginPlay();
// Spawn the Replicator of each plugin
ACogDebugReplicator::Spawn(this);
ACogAbilityReplicator::Spawn(this);
ACogEngineReplicator::Spawn(this);
}
- Implement Cog Interfaces on your desired actor classes:
```cpp
// CogSampleCharacter.h
UCLASS(config=Game)
class ACogSampleCharacter : public ACharacter
[...]
, public ICogCommonDebugFilteredActorInterface
, public ICogCommonAllegianceActorInterface
[...]
// CogSamplePlayerController.h
UCLASS(config=Game)
class ACogSamplePlayerController
: public APlayerController
, public ICogCommonPossessorInterface
Currently, Cog does not properly work when running under a single process in multiplayer mode. You might want to disable the setting Editor Preferences - Run Under One Process
: