How to determine client or server in VS debugger

how to determine if a breakpoint was triggered on the server or on the client? In VS debugger without modifying code?

AActor has its network role saved as member (Role). If your breakpoint is inside an actor class, you can check this variable directly in the debugger watch window. If the breakpoint is inside an actor component, you have to type something like PawnOwner->Role.

Since this is still the #1 result on Google related to debugging server vs client on Visual Studio, I’ll add that you can use the following expressions to check whether you’re on a server or which client the current code context is being executed. Just put them into the “evaluate expression” section of your IDE’s debugger and you’ll get a string giving you those details:

UE4 on Visual Studio:
UE4Editor-Engine!GPlayInEditorContextString

UE4 on Rider:
{,,UE4Editor-Engine.dll}GPlayInEditorContextString

UE5 on Visual Studio:
UnrealEditor-Engine!GPlayInEditorContextString

UE5 on Rider
{,,UnrealEditor-Engine.dll}::GPlayInEditorContextString

4 Likes

Thank you for this, I’ve been looking for a solution to this simple problem for ages. That said, it seems that the syntax for Rider requires two commas after the opening brace, i.e.

{,,UE4Editor-Engine.dll}::GPlayInEditorContextString
{,,UnrealEditor-Engine.dll}::GPlayInEditorContextString

Ah, yes, you’re right! Typo on my part. Will edit my original answer.

EDIT: Lol, it was the HTML formatting eating one of the commas :person_shrugging:

Thank you! Very, very helpful!