Player State's "Is Spectator" bool not updating value (What sets this variable?)

At the sacrifice of no longer having a purely blueprint-only game, unfortunately proving that you can’t make a game with just blueprints, I came up with this:

// ForceUpdateSpectatorStatus.cpp
#include "ForceUpdateSpectatorStatus.h"

void UForceUpdateSpectatorStatus::ForceUpdateSpectatorStatus(APlayerState* PlayerState, bool bNewSpectatorStatus)
{
    if (PlayerState)
    {
        PlayerState->SetIsSpectator(bNewSpectatorStatus);
    }
}

// ForceUpdateSpectatorStatus.h
#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GameFramework/PlayerState.h"
#include "ForceUpdateSpectatorStatus.generated.h"

UCLASS()
class UForceUpdateSpectatorStatus : public UBlueprintFunctionLibrary
{
    GENERATED_BODY()

public:
    UFUNCTION(BlueprintCallable, Category = "Player State")
    static void ForceUpdateSpectatorStatus(APlayerState* PlayerState, bool bNewSpectatorStatus);
};


This overwrites the state of the bool, whether the engine wants you to or not. This means the bool won’t go to waste, no variable left behind is my motto.

Please don’t ask me how it works, I don’t have the slightest idea, and honestly I’ll be waiting for my game to pay for a CS degree before I even dare bother.

More importantly, to the future user reading this post 2 years from now because it somehow became the first result in Google. If I were you, I’d just give up, I’m serious here, clearly some parts of the engine are not meant to work, be used, or even acknowledged. Just make a second replicated bool and use that instead while pretending that the original one does not exist, being as stubborn as me is not worth the RAM, time, and sanity sacrifices involved in installing and running Visual Studio. If you insist, at least use Visual Studio Code, it can build too, and it’s not as awful.

1 Like