Course contentsShow
← Unreal Engine Game Development
Lesson 467 of 8806. AI, Navigation, and Decision MakingFree lesson

Configuring the Visual Logger for Real-Time AI Tracking

You will set up the Visual Logger to record and visualize complex AI state changes and pathfinding data during live gameplay sessions.

In this lesson, you will learn how to configure the Unreal Engine Visual Logger to capture real-time AI state transitions and pathfinding data, transforming complex logic into a visual timeline you can scrub through.

Why the Visual Logger Matters

While standard log macros are useful, they lack the spatial and temporal context needed to debug AI. The Visual Logger allows you to record snapshots of your AI’s Blackboard values, Behavior Tree execution status, and Pathfinding queries directly into the 3D world. By binding your custom state transitions to the Visual Logger, you can "rewind" gameplay to see exactly why an agent switched from an "Idle" state to an "Attack" state at a specific millisecond.

Configuring Your Actor for VLog

To make your AI compatible, your class (typically inheriting from AActor or ACharacter) must implement the IVisualLoggerDebugInterface. You primarily use the UE_VLOG macro to send data to the logger.

To capture state changes, place the macro inside your state-switching logic:

#include "VisualLogger/VisualLogger.h"

void AMyAICharacter::ChangeState(EAIState NewState)
{
    CurrentState = NewState;
    
    // Log the state transition for playback
    UE_VLOG(this, LogTemp, Verbose, TEXT("AI State Changed to: %s"), *UEnum::GetValueAsString(NewState));
    
    // You can even draw spatial data!
    UE_VLOG_LOCATION(this, LogTemp, Verbose, GetActorLocation(), 50.f, FColor::Red, TEXT("State Change Point"));
}

Visualizing Pathfinding and Perception

Beyond simple text, you can track pathfinding by leveraging the built-in hooks within the NavigationSystem. When the Visual Logger is active (press ' or use the command VisLog), it will automatically visualize the NavPath of your agents. For complex logic, use UE_VLOG_SEGMENT or UE_VLOG_ARROW to visually represent the target the AI is currently calculating, allowing you to confirm that the agent is not just choosing the wrong state, but is also receiving faulty navigation data.

By integrating these calls into your state transitions and pathing logic, you create a synchronized history of your AI’s decision-making process.

Key Takeaway: Integrating UE_VLOG into your AI’s state machine transitions allows you to map internal code logic directly to 3D spatial debugging, enabling precise analysis of why an AI acted at a specific time and location.