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);
}