Header:
class BUGFIX_API APossessablePawn : public APawn
{
GENERATED_BODY()
public:
// Constructor and destructor
APossessablePawn();
public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
USceneComponent* ExitPoint;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
USkeletalMeshComponent * SkeletalMeshComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
UStaticMeshComponent * StaticMeshComponent;
};
CPP:
APossessablePawn::APossessablePawn():APawn()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
StaticMeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(MakeUniqueObjectName(this, UStaticMeshComponent::StaticClass(), TEXT("PossessableBaseMesh")));
SkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(MakeUniqueObjectName(this, USkeletalMeshComponent::StaticClass(), TEXT("PossessableAnimMesh")));
ExitPoint = CreateDefaultSubobject<USceneComponent>(MakeUniqueObjectName(this, USceneComponent::StaticClass(),TEXT("ExitLocation")));
RootComponent = StaticMeshComponent;
SkeletalMeshComponent->SetupAttachment(StaticMeshComponent);
ExitPoint->SetupAttachment(SkeletalMeshComponent);
}
Working in editor, but after a package all three of these components are being set to null and the actor is moved to the origin (probably because the root is null). This originally was a bug in a larger file in a larger project but for testing purposes has been moved to it’s own isolated project. I have no Idea how to fix this, everything I have tried has either changed nothing or made it not work in editor. Log File For the Package
Edit:
Also just to be clear this code has been tried on multiple PC’s in two separate projects with the same problem. There are a couple of errors in the log file, but I can’t figure out why they are there.