Arnaud Jamin 88481c3dcc input actions
2023-10-11 14:50:51 -04:00
2023-10-09 02:20:52 -04:00
2023-10-11 14:50:51 -04:00
2023-10-10 17:24:27 -04:00
2023-10-02 01:32:41 -04:00
2023-10-11 14:40:21 -04:00
2023-10-10 00:20:12 -04:00
2023-10-02 01:30:11 -04:00
2023-10-02 17:27:30 -04:00
2023-10-02 01:32:41 -04:00
2023-10-02 01:30:11 -04:00
2023-10-11 01:37:57 -04:00
2023-10-10 17:43:42 -04:00

Cog

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

image

ImGui Windows

General Notes

  • Press the [Insert] key or use the Cog.ToggleInput console command to open the Imgui Main Menu.
  • Most windows display their contents based on a selected actor.
  • The selector actor can be chosen using the selection window or widget.
  • Mouse over a window title to display its help. This behavior can be disabled in the Window menu.
  • Window Layouts can be saved/loaded.
  • Windows save their own settings in a Cog.ini file to maintain their state between multiple sessions.

Abilities

Displays the gameplay abilities of the selected actor.

Abilities

  • Click the ability checkbox to force its activation or deactivation.
  • Right click an ability to remove it, or open/close the ability separate window.
  • Use the 'Give Ability' menu to manually give an ability from a list defined in a Data Asset.

Actions

Displays the state of Input Action.

image

  • Can be used to inject inputs to help debugging.
  • The display input action are read from a Input Mapping Context defined in a Data Asset.

Attributes

Displays the gameplay attributes of the selected actor

image

  • Attributes can be sorted by name, category or attribute set.
  • Attributes with the Current value greater than the Base value are displayed in green.
  • Attributes with the Current value lower than the Base value are displayed in red.
  • Use the options 'Show Only Modified' to only show the attributes that have modifiers.

Cheats

Used to apply cheats to the selected actor.

image

  • The cheats are gameplay effects configured in a data asset.
  • Key modifiers can be used to change which actor should be affected by the cheat:
    • [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 actor

Collisions

Used to inspect collisions by performing a collision query with the selected channels.

image

  • The query can be configured in the options.
  • The displayed collision channels can be configured in a Data Asset.

Debug Settings

Used to tweak how the debug display is drawn.

image

Effects

Displays the gameplay effects of the selected actor.

image

  • Mouse over an effect to see its details such as its modifiers, the gameplay tags it grants, the remaining time.

Gamepad

Display the state of the gamepad

image

  • Can be used to inject inputs to help debugging.

Log Categories

This window can be used to activate and deactivate log categories

image

  • Activating a log category set its verbosity to VeryVerbose.
  • Deactivating a log category set its verbosity to Warning.
  • The detailed verbosity of each log category can shown by using the Option menu.
  • A client can modify the verbosity of the server.
  • The log categories are used to display both output log and debug display in the world.

Metric

This window gather values generated by the selected actor to compute how much output it produces or receives per second. This is typically useful to compute the damage dealt per second, the damage received per second, etc.

image

Net Emulation

This window is used to configure the network emulation

image

Output Log

Display the output log based on each log categories verbosity.

image

  • The verbosity of each log category can be configured in the 'Log Categories' window.

Pools

Displays attributes of the selected actor as pools.

image

  • The pools can be configured in a data asset.

Plots

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

image

Scalability

Used to configure the rendering quality.

image

Skeleton

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

image

  • Mouse over a bone to highlight it.
  • Right click a bone to access more debug display.
  • Use the [Ctrl] key to toggle the bone debug draw recursively.

Selection

This window can be used to select an actor either by picking an actor in the world or by selecting an actor in the actor list.

image

  • The actor list can be filtered by actor type (Actor, Character, etc).
  • The current selection is used by various debug windows to filter out their content.

Spawn

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

image

Stats

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

image

Tags

Displays gameplay tags of the selected actor.

image

Time Scale

Used to change the game global time scale.

image

  • If changed on a client the time scale is also modified on the game server.

Tweaks

Used to apply tweaks to all the spawned actors

image

  • The tweaks are used to test various gameplay settings by actor category
  • The tweaks can be configured in a data asset.

Debug Functionalities

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

image

Log and debug functions can be filtered to only what is outputted by the selected actor.

image

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 [Insert] 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:

  • CogSample - A Sample that demonstrate various Cog functionalities. The project was saved in Unreal 5.1
  • Plugins/CogAbility - ImGui windows for the Gameplay Ability System (Abilities, Effects, Tags, ...)
  • Plugins/CogInput - ImGui windows for the Enhanced Input library (Input action, Gamepad)
  • Plugins/CogEngine - ImGui windows for the core unreal engine functionalities (Log, Stats, Time, Collisions, Skeleton, ...)
  • Plugins/CogWindow - ImGui window management (Base Window, Layout)
  • Plugins/CogDebug - Debug functionalities (Log, Debug Draw, Plot, Metric, ...)
  • Plugins/CogImGui - Integration of Imgui for Unreal, inspired by UnrealImGui
  • Plugins/CogCommon - Common headers

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.

  • Setup up module dependencies:
// CogSample.Build.cs
using UnrealBuildTool;

public class CogSample : ModuleRules
{
    public CogSample(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
        PublicDependencyModuleNames.AddRange(new string[] 
        { 
            "CogCommon",  // The CogCommon is required on all target configuration
            "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[]
            {
                "CogDebug",
                "CogImgui",
                "CogWindow",
                "CogEngine",
                "CogInput",
                "CogAbility",
            });
        }
    }
}
  • In the class of your choice (in the sample we use the GameState class) add a reference to the CogWindowManager:
// 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
};
  • Instantiate the CogWindowManager and add some windows:
// ACogSampleGameState.cpp
void ACogSampleGameState::BeginPlay()
{
    Super::BeginPlay();

#if ENABLE_COG
    CogWindowManager = NewObject<UCogWindowManager>(this);
    CogWindowManagerRef = CogWindowManager;

    // Add windows
    CogWindowManager->CreateWindow<UCogEngineWindow_DebugSettings>("Engine.Debug Settings");
    CogWindowManager->CreateWindow<UCogEngineWindow_ImGui>("Engine.ImGui");

    // Add windows that uses a data asset. The data asset must be created inside Unreal Editor.
    const UCogAbilityDataAsset* AbilitiesAsset = GetFirstAssetByClass<UCogAbilityDataAsset>();

    UCogAbilityWindow_Abilities* AbilitiesWindow = CogWindowManager->CreateWindow<UCogAbilityWindow_Abilities>("Gameplay.Abilities");
    AbilitiesWindow->Asset = AbilitiesAsset;

    UCogAbilityWindow_Attributes* AttributesWindow = CogWindowManager->CreateWindow<UCogAbilityWindow_Attributes>("Gameplay.Attributes");
    AttributesWindow->Asset = AbilitiesAsset;

    [...]
#endif //ENABLE_COG
}
  • Define which key will toggle the input from the game to Imgui:
// ACogSampleGameState.cpp
FCogImguiModule::Get().SetToggleInputKey(FCogImGuiKeyInfo(EKeys::Insert));
  • Tick the CogWindowManager:
// ACogSampleGameState.cpp
void ACogSampleGameState::Tick(float DeltaSeconds)
{
    Super::Tick(DeltaSeconds);

#if ENABLE_COG
    CogWindowManager->Tick(DeltaSeconds);
#endif //ENABLE_COG
}
  • Implement Cog Interfaces on your desired actor classes:
// CogSampleCharacter.h
UCLASS(config=Game)
class ACogSampleCharacter : public ACharacter
    , public IAbilitySystemInterface
    , public ICogCommonDebugFilteredActorInterface
    , public ICogCommonAllegianceActorInterface
    , public ICogSampleTeamInterface
    , public ICogSampleTargetableInterface
// CogSamplePlayerController.h
UCLASS(config=Game)
class ACogSamplePlayerController 
    : public APlayerController
    , public ICogCommonPossessorInterface

__

  • In Unreal Editor create and configure the Data Assets
S
Description
No description provided
Readme MIT 390 MiB
Languages
C++ 98%
C 1.2%
C# 0.8%