Packaged Game: Input does not work and player's class has no name (bug)

Hello,

I am having an issue playing the project after it has been packaged. I strongly disbelief that one my project settings affect the issues I am experiencing though I cannot negate that for 100% certainty, yet I decided to post it in bugs.

Running the executable, my player spawns at the world’s origin with no input working; I am trying this with a (slightly modified) version of the first player template character whose parent I have reparented to a native custom character class. For debugging purposes, in the level blueprint, I have written a script to get the player controller at index 0 and print the pawn’s class: It prints "Player Class: " while I expected it to be “Player Class: FirstPersonCharacter_2”. When I play in editor or as standalone game, it correctly prints this. I have also tried getting the game mode active and getting the default pawn class and printing it; its name was also empty although I have set my custom class in the game mode.

I have ensured to set the right game mode and using the same technique as described above I had the correct class of the game mode printed. Also, I have set up a player start and set it to auto possess player at index 0. When I spawn the blueprint in the level and in the pawn category set it to auto possess player at index 0 nothing works either.

I believe that the engine is spawning my player pawn incorrectly as the class is not correct. I understand my project files may be required, I cannot publicly upload it because it contains plugin code I will want to sell on the marketplace; should you request access to the files, please point out how you would best receive them.

Cheers,
Univise

Update:

I noticed that when I place my blueprint in the level and in the pawn category set it to auto-possess player 0, then in the packaged game my player has the same rotation as it. However, input still does not work, the pawn’s class name is still empty, and the spawn point is still at the origin.

I also noticed that if I create a blueprint character that directly inherits from ACharacter, the class is found and spawns properly. If I inherit from my custom class, the issues occur.

Source:

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/Character.h"
#include "InputToggable.h"

#include "MyCharacter.generated.h"

class UInputComponent;

UCLASS()
class AMyCharacter : public ACharacter, public IInputToggable
{
	GENERATED_BODY()

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Questy, meta = (AllowPrivateAccess = "true"))
	bool bInputIsEnabled;

public:
	AMyCharacter();

	virtual void BeginPlay();
	
protected:

	virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;

public:

	FORCEINLINE bool GetIsUserInputEnabled() const
	{
		return bInputIsEnabled;
	}

protected: /* Quest Input */

	void OnShowQuestMenu();

	void OnAbortDialogue();

	void OnPrimaryInteractDown();

	void OnPrimaryInteractUp();

public: /* Input Toggable Interface */

	virtual void DisableUserInput_Implementation() override
	{
		bInputIsEnabled = false;
	}

	virtual void EnableUserInput_Implementation() override
	{
		bInputIsEnabled = true;
	}

};


// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#include "MyProject.h"
#include "MyCharacter.h"

#include "InteractorComponent.h"
#include "DialogueInitiatorComponent.h"
#include "MyHUD.h"

DEFINE_LOG_CATEGORY_STATIC(LogFPChar, Warning, All);

//////////////////////////////////////////////////////////////////////////
// AMyCharacter

AMyCharacter::AMyCharacter()
{
	bInputIsEnabled = true;
}

void AMyCharacter::BeginPlay()
{
	Super::BeginPlay();
}

void AMyCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	// set up gameplay key bindings
	check(InputComponent);

	InputComponent->BindAction("Interact", IE_Pressed, this, &AQuestyCharacter::OnPrimaryInteractDown);
	InputComponent->BindAction("Interact", IE_Released, this, &AQuestyCharacter::OnPrimaryInteractUp);
	InputComponent->BindAction("Pause", IE_Pressed, this, &AQuestyCharacter::OnAbortDialogue);
	InputComponent->BindAction("QuestMenu", IE_Pressed, this, &AQuestyCharacter::OnShowQuestMenu);
}

void AMyCharacter::OnShowQuestMenu()
{
	APlayerController* Controller = Cast<APlayerController>(GetController());
	if (Controller == NULL)
	{
		return;
	}

	AQuestyHUD* HUD = Cast<AQuestyHUD>(Controller->GetHUD());
	if (HUD == NULL)
	{
		return;
	}

	HUD->ToggleQuestMenu(this); 
}

void AMyCharacter::OnAbortDialogue()
{
	UDialogueInitiatorComponent* Comp = Cast<UDialogueInitiatorComponent>(GetComponentByClass(UDialogueInitiatorComponent::StaticClass()));
	if (Comp == NULL)
	{
		return;
	}

	Comp->EndDialogue();
}

void AMyCharacter::OnPrimaryInteractDown()
{
	if (!bInputIsEnabled)
	{
		return;
	}

	UInteractorComponent* Component = Cast<UInteractorComponent>(GetComponentByClass(UInteractorComponent::StaticClass()));
	if (Component == NULL)
	{
		return;
	}

	FInteractionEvent Event;
	Event.bPressed = true;
	Event.Key = FString("Primary");
	Component->OnInteractionKeyPressed(Event);
}

void AMyCharacter::OnPrimaryInteractUp()
{
	if (!bInputIsEnabled)
	{
		return;
	}

	UInteractorComponent* Component = Cast<UInteractorComponent>(GetComponentByClass(UInteractorComponent::StaticClass()));
	if (Component == NULL)
	{
		return;
	}

	FInteractionEvent Event;
	Event.bPressed = false;
	Event.Key = FString("Primary");
	Component->OnInteractionKeyPressed(Event);
}

Hi Univise,

  • Does this occur in a clean, blank project with no additional content or is it limited to one project?
  • What steps can I take to reproduce this on my end?
  • When creating the character blueprint that is inherited from your character blueprint, are you doing this via c++ and exposing to blueprints or is everything done through blueprints?

Sorry for the late response. Please do not close the post: I am still producing results to report. I will present my results by tomorrow.

I do not quite understand the third point: What exactly is meant by “creating”? Do you mean spawning? Do you mean writing the blueprint?

I tried to reproduce the error in a blank project with just my plug-in installed, as that contains the class in question, but to no avail. I have followed the same steps as those that caused the problem in my original project.

I do not quite understand what it meant by the third point. Is creating spawning? writing the blueprint? something else?

Because I cannot reproduce the error in a new project, I believe that the error is occuring due to a setting that I might have made to the project in which it occured. I have played around a lot so it might be that. I had to fix the error in my original project; I was unable to keep a copy of the unfixed project but I believe I might be able to reproduce it in there - should you ask for a copy of the project to inspect. I think that would be an overkill for a minor bug like this, but I am open to it.

Thank you for your support.

Hi Univise,

What I mean is is the child character actor made in c++ or is it made in blueprints? Where is the functionality being put together and compiled?

The character to use is a blueprint and it inherits from the C++ class in my post. The blueprint adds movement functionality, which is nearly identical to the first person template.

Hey Univise-

Just to clarify, are you still seeing the problem of your player controller not returning anything when printed? Can you provide a screenshot the blueprint where you’re setting up your possession?

As for the input, I noticed in your SetupPlayerInputComponent function that you are not calling the parent functionality. Please try adding Super::SetupPlayerInputComponent(InputComponent); at the start of the class and let me know if that has any affect on your input.

I am taking your steps momentarily but it should not be expected that the call to the super function should make a difference as the input worked in a blank project. I thank you for pointing it out thought; a super call should always be performed by default unless there is a reason not to.

The character is auto possessed. There is no custom code for that.

As you mentioned, the input is working in a newly created/packaged project and unfortunately there are references in the class you provided that prevent it from compiling after being added to a project. If you’re able to reproduce the input behavior in a new project with minimal added content, please provide the sample project and/or the setup steps used to create the project to help me reproduce the behavior locally.

I am noting down this post, and will contact you if something comes up. Thank you for your support. Until then, I suggest locking this post up.

Hey Univise-

At your suggestion I am marking this as resolved for the time being. If you do find more information, feel free to add a new comment to reopen the post for further investigation.