arnaud-jamin / Cog

Cog is a set of debug tools for Unreal Engine built on top of Dear ImGui
MIT License
357 stars 44 forks source link

Cog

Cog is a set of debug tools for Unreal Engine built on top of Dear ImGui

Cog

Cog provides:

General Info:

Cog Windows

Abilities

Displays the gameplay abilities of the selected actor.

[Abilities]()

Actions

Displays the state of Input Action.

Actions

Attributes

Displays the gameplay attributes of the selected actor.

Attributes

Behavior Tree

Displays the behavior tree of the selected actor.

Behavior Tree

Blackboard

Displays the blackboard of the selected actor.

Blackboard

Cheats

Used to apply cheats to the selected actor.

Cheats

Collisions Tester

Used to test a collision query

Collisions Tester Collisions Tester

Collisions Viewer

Used to inspect collisions in the world

Collisions Viewer

Command Bindings

Used to configure the command bindings.

Command Bindings

Debug Settings

Used to tweak how the debug display is drawn.

Debug Settings

Effects

Displays the gameplay effects of the selected actor.

Effects

Gamepad

Display the state of the gamepad

Gamepad

Inspector

Used to inspect and modify an Object properties

Inspector

Log Categories

Can be used to activate and deactivate log categories

Log Categories

Metric

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.

Metric

Net Emulation

Used to configure the network emulation

Net Emulation

Output Log

Display the output log based on each log categories verbosity.

Output Log

Pools

Displays attributes of the selected actor as pools.

Pools

Plots

Plots values and events overtime. When applicable, only the values and events of the selected actor are displayed.

Plots

Scalability

Used to configure the rendering quality.

Scalability

Skeleton

Display the bone hierarchy and the skeleton debug draw of the selected actor if it has a Skeletal Mesh.

Skeleton

Selection

Used to select an actor either by picking an actor in the world or by selecting an actor in the actor list.

Selection

Settings

Configure the settings of Cog Windows.

Settings

Spawn

Used to spawn new actors in the world. The spawn list can be configured in a Data Asset.

Spawn

Stats

Displays engine stats such as FPS, Ping, Packet Loss.

Stats

Tags

Displays the gameplay tags of the selected actor.

Tags

Time Scale

Used to change the game global time scale.

Time Scale

Transform

Used to read and set the selected actor transform.

Transform

Transform

Tweaks

Used to apply tweaks to all the spawned actors

Tweaks

Debug Functionalities

Cog provides C++ and Blueprint functions to log and debug draw within Log Categories.

Log Categories

Log and debug draw functions can be filtered by the selected actor.

Log and debug draw functions

Setup

Testing the sample

You must have Unreal 5.1 or greater and Visual Studio to launch the sample

  1. Download the code
  2. Right Click Cog.uproject and click Generate Visual Studio project files
  3. Open Cog.sln
  4. Select the DebugGame Editor or Development Editor solution configuration
  5. Make sure Cog is set as the startup project
  6. Start Debugging (F5)
  7. Once in Unreal, press Play (Alt+P)
  8. Press the [F1] key or use the Cog.ToggleInput console command to open the Imgui Main Menu.

Integrating Cog in your project

The Cog repository has the following structure:

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.

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
};

if ENABLE_COG

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");

[...]

endif //ENABLE_COG

}


- 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
}

if ENABLE_COG

// Spawn the Replicator of each plugin
ACogDebugReplicator::Spawn(this);
ACogAbilityReplicator::Spawn(this);
ACogEngineReplicator::Spawn(this);

endif //ENABLE_COG

}


- 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

Data Assets

Data Assets

Data Assets

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:

image