How do I get a debug message to show on only one screen in a multiplayer game?

I am making a multiplayer game running off a dedicated server and everytime I use: “GEngine->AddOnScreenDebugMessage(-1, 300.f, FColor::Blue, TEXT(“Message”));”, it shows up on every player’s screen on the server. How can I get it to only show up on one Player screen?

For example, I would like to have each player to get a debug message saying which team they are on and only that screen can see it.

Also I’m only using 4.4.3

Thanks

2 Likes

#IsLocallyControlled()

If you do this in your character class:

if(IsLocallyControlled())
{
   //print your debug message
}

It will only show on the local owning player of the character in which you call this function

:slight_smile:

Rama

1 Like

This didn’t work for me. All the messages showed up on all of the players still. I did use this right:
if (IsLocallyControlled()){
GEngine->AddOnScreenDebugMessage(-1, 300.f, FColor::Blue, TEXT(“Blue”));
}

The engine itself doesn’t have an option for local or owner based debug messages; looking through the API there is a variable called: “bEnableOnScreenDebugMessagesDisplay” which may help.

What I would do is create a HUD element specifically for your own debug messages, then send them to whichever player you want, with whatever font you want. It may be a little less simple than that though as I haven’t touched HUD yet.

1 Like

I know this is almost 10 years later, but I thought I would mention this in case anyone is looking back on this question now.

(This information comes from experience with UE4 and UE5, it may change in the future)

If you are testing your game from within the editor (PIE or clients in separate windows), it will always show on all of the client windows that open. For this reason, you may also see something print to screen 2+ times when you only call it once.

If you instead package the game and then test it, you should see that it only prints on the one client you are trying to print it on and it only prints one time, assuming you are calling it properly.

5 Likes

Adding onto this, unchecking
Editor Preferences -> Play -> Multiplayer Options -> Run Under One Process
will also fix this.

It seems like the onscreen print messages are on a per process basis. Although notably this will run much slower, as each window is running a different instance of Unreal. Much faster than packaging every time you want to test though!

4 Likes