Game works in editor, and packaging succeeds, but opening the exported package fails

Hi,

I am trying to package my game so that it can be run outside the editor, however I can’t get it to work. I can compile my game and it runs perfectly within the engine, I then package it and it succeeds, but then I open it and it doesn’t even get to the level it just pops of a Fatal Error message. It just says EXCEPTION_ACCESS_VIOLATION and does not tell me where. Again, this works in the editor??

It seems to fail around the EnemyCharacter class so here is the whole file, sorry for their length :frowning:

header:

#pragma once

#include "CoreMinimal.h"
#include "GameCharacter.h"
#include "UObject/NoExportTypes.h"
#include "Engine/DataAsset.h"
#include "EnemyCharacter.generated.h"

class UEnemyAnimInstance;
class AEnemyAI;
class UVisionComponent;
class UDistanceToControllerComponent;
class UHealthComponent;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// UEnemyBlackboard Class

/**
*	Blackboard class representing the values associated with  
*/
USTRUCT()
struct FEnemyBlackboard
{

	GENERATED_USTRUCT_BODY()

	/** Default Constructor */
	FEnemyBlackboard() {};

	/** Boolean value indicating whether the NPC is currently in cover */
	UPROPERTY()
	bool bIsInCover = false;

	/** Boolean value indicating whether the NPC should attack */
	UPROPERTY()
	bool bShouldAttack = true;
};


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  AEnemyCharacter class

/**
*   Class controlling the representation of an NPC Character
*	whithin the game
*/
UCLASS()
class TMO_API AEnemyCharacter : public AGameCharacter
{
	GENERATED_BODY()

public:
	/** Default constructor for the AEnemyCharacter class */
	AEnemyCharacter();

	/** VisionComponent */
	UPROPERTY()
	UVisionComponent* Vision;

	/** DistanceCheck Component */
	UPROPERTY()
	UDistanceToControllerComponent* DistanceChecker;

protected:
	/** Animation Controller for the NPC */
	UPROPERTY()
	UEnemyAnimInstance* AnimController;

	/** AIController which controls the MPC character */
	UPROPERTY()
	AEnemyAI* CharacterAIController;

	/**
	*	Variable declaring if the NPC will be declared in blueprints (true) or randomly
	*	generated (false)
	*/
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = NPCSettings)
	bool bIsDeclaredInBlueprints = false;

	/**
	*	Variable delcaring the max speed of the NPC within the game, this value
	*	will be overwritten if IsDeclaredBlueprints is not set to false (unchecked)
	*/
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = NPCSettings)
	float MaxSpeed = 400.f;

protected:

	/** Function called after the constructor but before play begins */
	virtual void BeginPlay() override;

public:

	/** Function called to setup the blackboard component */
	virtual FEnemyBlackboard* SetupBlackboardComponent();

	/** Function called to warn the squad */
	virtual void WarnSquad();

	/** Function called to alter the speed of the character by a fraction of the max speed*/
	virtual void ChangeSpeedToFraction(float Fraction);

	/** Function called to melee attack the opponent */
	virtual void MeleeAttackOpponent();

	/** Function called by VisionComponent when player spotted */
	virtual void PlayerSearchResult();

	/** Function called when the distance component returns true */
	void SquadRadiusEntered(bool isGreaterThan);

	/** Function called to activate the DistanceToControllerComponent */
	void SetupStandardDistanceComponent();

	/** Function called to activate the VisionComponent */
	void SetupStandardVisionComponent();

	/** Function called to deactivate the DistanceToControllerComponent */
	void DeactivateDistanceComponent();

	/** Function called to deactivate the VisionComponent */
	void DeactivateVisionComponent();

public:
	/** Getter for the AnimController instance */
	FORCEINLINE UEnemyAnimInstance* GetAnimController() const { return AnimController; }
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

cpp file

#include "EnemyCharacter.h"
#include "EnemyAI.h"
#include "EnemyAnimInstance.h"
#include "Engine.h"
#include "TMO.h"
#include "Components/CapsuleComponent.h"
#include "VisionComponent.h"
#include "NPCBlackboard.h"
#include "SquadNPCBlackboard.h"
#include "HealthComponent.h"
#include "DistanceToControllerComponent.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "Runtime/Engine/Classes/GameFramework/Controller.h"

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  AEnemyCharacter class

/** Default constructor for the AEnemyCharacter class */
AEnemyCharacter::AEnemyCharacter()
	: Super()
{

	// Set size for collision capsule
	GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
	RootComponent = GetCapsuleComponent();

 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	// Setup DistanceChecker for search purposes
	DistanceChecker = CreateDefaultSubobject<UDistanceToControllerComponent>(TEXT("DistanceCheckComponent"));
	AddOwnedComponent(DistanceChecker);

	// Setup VisionComponent to search for the player
	Vision = CreateDefaultSubobject<UVisionComponent>(TEXT("VisionComponent"));
	AddOwnedComponent(Vision);

	UE_LOG(NPCCharacterLog, Log, TEXT("Finsihing Enemy Character's Constructor"));
}

/** Function called to setup the blackboard component */
FEnemyBlackboard* AEnemyCharacter::SetupBlackboardComponent()
{
	return new FEnemyBlackboard();
}

/** Function called to warn the squad */
void AEnemyCharacter::WarnSquad()
{
	AnimController->PerformWarnSquad();
	AnimController->FunctionToCall.BindUObject(CharacterAIController, &AEnemyAI::IndicatePlayerSpotted);
}

/** Function called to alter the speed of the character */
void AEnemyCharacter::ChangeSpeedToFraction(float Fraction)
{
	AnimController->SetSpeed(MaxSpeed * Fraction);
	GetCharacterMovement()->MaxWalkSpeed = MaxSpeed * Fraction;
}

/** Function called by VisionComponent when player spotted */
void AEnemyCharacter::PlayerSearchResult()
{
	DeactivateVisionComponent();
	CharacterAIController->PlayerSpotted();
}

/** Called when the game starts or when spawned */
void AEnemyCharacter::BeginPlay()
{
	Super::BeginPlay();

	#if !UE_BUILD_SHIPPING
		UE_LOG(NPCCharacterLog, Log, TEXT("Calling Enemy Character's C++ BeginPlay"));
	#endif // DEBUG

	GetCharacterMovement()->MaxWalkSpeed = MaxSpeed;

	CharacterAIController = Cast<AEnemyAI>(GetController());

	// Setup AnimController
	AnimController = Cast<UEnemyAnimInstance>(GetMesh()->GetAnimInstance());
	AnimController->FunctionToCall.BindUObject(CharacterAIController, &AEnemyAI::NextTask);

	Vision->PrimaryComponentTick.SetTickFunctionEnable(false);

	SetupStandardDistanceComponent();

	GetMesh()->SetCollisionResponseToChannel(ECC_Camera, ECR_Ignore);
	UE_LOG(NPCCharacterLog, Log, TEXT("Finishing BeginPlay"));

}

/** Function called to melee attack the opponent */
void AEnemyCharacter::MeleeAttackOpponent()
{
	AnimController->PerformMeleeAttack();
	CharacterAIController->ApplyDamageToPlayer(50);
}

/** Function called to activate the DistanceToControllerComponent */
void AEnemyCharacter::SetupStandardDistanceComponent()
{
	if (DistanceChecker)
	{
		DistanceChecker->Activate();
		DistanceChecker->SetComponentTickEnabled(true);
		DistanceChecker->FunctionToCall.BindUObject(this, &AEnemyCharacter::SquadRadiusEntered);
	}
}

/** Function called to deactivate the DistanceToControllerComponent */
void AEnemyCharacter::DeactivateDistanceComponent()
{
	if (DistanceChecker)
	{
		DistanceChecker->PrimaryComponentTick.SetTickFunctionEnable(false);
		DistanceChecker->Deactivate();
	}
}

/** Function called to activate the VisionComponent */
void AEnemyCharacter::SetupStandardVisionComponent()
{
	if (Vision)
	{
		Vision->Activate();
		Vision->SetComponentTickEnabled(true);
		Vision->FunctionToCall.BindUObject(this, &AEnemyCharacter::PlayerSearchResult);
	}
}

/** Function called to destroy the VisionComponent */
void AEnemyCharacter::DeactivateVisionComponent()
{
	if (Vision)
	{
		Vision->PrimaryComponentTick.SetTickFunctionEnable(false);
		Vision->Deactivate();
	}
}

/** Function called when the distance component returns true */
void AEnemyCharacter::SquadRadiusEntered(bool isGreaterThan )
{
	DeactivateDistanceComponent();
	CharacterAIController->AttachControllerToSquad();
	SetupStandardVisionComponent();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Is there any other files I can look at to attempt to find the problem? I have been working on this problem for hours :frowning:

Log for the Packaged Game
link text

Crash log from the Crashes folder link text

Thanks for any and all help