How can I pause a game running on a dedicated server?

It’s been a month, let’s bump this thing back into circulation!

Another quiet month. Let’s see if a little bump can get this question in front of the right set of eyes :slight_smile:

Hi, did you manage to solve this? My dedicated server doesn’t want to pause self.

Unfortunately, not yet.
I think the legal and purchasing teams are making headway on updating our licensing though, which might give me a more direct line of support from Epic than I’ve had up to this point. Hopefully that will lead to a solution. And if it does, I’ll make sure to update this post!

You can solve it by using SetPause with c++.

void APlayerControllerGame::BP_Pause(bool flag)
{
	SetPause(flag);
}

Good morning!

I’m trying to see if this will work for me, but I’m struggling to create a C++ PlayerController that I can actually use. I’m able to compile successfully in Visual Studio, but the PlayerController class doesn’t show up in the editor (I can’t select it as the default PlayerController for a GameMode, and I can’t construct an instance of it using the ConstructObjectFromClass node).

I’m attaching the .h and .cpp files for the test PlayerController. Any idea what I might have done wrong?

why would you put SetPauseState definition inside of constructor body?

Great question! Mostly because I’m still a bit of a novice when it comes to C++, and didn’t immediately recognize that scope as being the constructor :wink: I saw the final closing curly brace and assumed it was the end of the class (Java habits haha).

Unfortunately, fixing this doesn’t seem to have made the PausePlayerController available in the editor. It’s strange that it builds correctly, but doesn’t produce something I can see from Blueprints. Maybe there’s an issue with some of my UE4 markup?

Did you try regenerating project files and compling in editor?

I created a simple code.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "PausePlayerController.generated.h"

/**
 *
 */
UCLASS()
class PAUSETEST_API APausePlayerController : public APlayerController
{
	GENERATED_BODY()

	UFUNCTION(BlueprintCallable)
	void SetPauseState(bool paused);
};

// Fill out your copyright notice in the Description page of Project Settings.

#include "PausePlayerController.h"

void APausePlayerController::SetPauseState(bool paused)
{
	SetPause(paused);
}

So it looks like the differences between your code and mine are:

  1. Different includes
  2. No “Blueprintable” and “BlueprintType” in the UCLASS declaration
  3. No constructor specified

I’ll try making those changes as soon as I get a chance. It probably won’t be until a little later this week though - the next couple of days are likely to be busy with meetings and demos.

laggyluk - if the code changes don’t do the trick, I can try regenerating the project files and using the in-editor compile button.

I’ll let you guys know how it goes as soon as I’m able to get back to working on this. Thanks again for the help! :slight_smile:

Finally got it!

Thank you so much にゃんたまランド, I hadn’t even thought to try a C++ version of the PlayerController for pausing!

The reason my C++ PlayerController wasn’t appearing in Blueprint was probably that I had created it in Visual Studio, not in the UE editor. The tip from laggyluk actually helped me identify that - regenerating the project deleted my new PlayerController class, which made me realize that UE4 just had no idea it existed.

For anyone who already has a Blueprint-based PlayerController that they’re using, remember that you can change its parent. Doing so gave me access to the new SetPauseState function from within my existing Blueprint PlayerController.

Anyway, I just wanted to say thanks again for the help - I really do appreciate it!