[4.14.1] PlayerController tick function being called when opening blueprint editor

As the title says, my player controller’s tick function is called when I open it in the blueprint editor. My blueprint inherits from a custom player controller c++ class. You can take the following steps to recreate it.

  • Create a class that inherits PlayerController
  • Override the tick function and have it print to the console.
  • Create a blueprint that inherits your custom class
  • Open the new blueprint in the editor

Now your poor log will be spammed :frowning:

Resulting C++

Header file

#pragma once

#include "GameFramework/PlayerController.h"
#include "MyPlayerController.generated.h"

UCLASS()
class BUGREPRODUCTION_API AMyPlayerController : public APlayerController
{
	GENERATED_BODY()
	virtual void Tick(float DeltaTime) override;
};

Implementation file

#include "BugReproduction.h"
#include "MyPlayerController.h"

void AMyPlayerController::Tick(float DeltaTime)
{
	UE_LOG(LogTemp, Error, TEXT("Tick!"));
}

I over complicated this, no C++ class required. It’s the same bug that was posted here.

I came up with a hacky workaround if you overwrote your tick method with C++.

void MyPlayerController::Tick(float DeltaTime)
{
	if (GetWorld()->WorldType == EWorldType::EditorPreview) return;
	// the rest of your tick function...
}

Add the 3rd line to the top of your tick function. The code is checking the world type. When the blueprint editor calls the function (which it shouldn’t) the world type is “Editor Preview”. So if WorldType == EditorPreview, return!

If you overwrote the tick function in blueprint, I don’t know how to help since you won’t be able to open it (if the resulting code causes the editor to crash) :frowning: I don’t like hacks so hopefully we can get this resolved soon :slight_smile:

Hey chatrat12-

As you mentioned, this bug is currently a known issue and is open for investigation in our system. To help maintain information in a single place for tracking and ease of searching, I will be marking this post as resolved in order to concentrate information on the post here: [4.7.6] Player controller tick event fires in editor - Character & Animation - Unreal Engine Forums .

Cheers

Doug Wilson

I can confirm this bug is still an issue in 4.14.2 as it wasted 6 hours of my life…

This is causing very non-intuitive hard to debug crashes when opening PlayerController blueprints.