Calling CreateDefaultSubobject crashes editor!

Yes, it inherits from AActor. I can paste that class if it will help…
Source:



// Fill out your copyright notice in the Description page of Project Settings.

#include "RSGame.h"
#include "InteractiveObject.h"
#include <typeinfo>


// Sets default values
AInteractiveObject::AInteractiveObject()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	meshcomp = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh"));
	meshcomp->CastShadow = true;
	RootComponent = meshcomp;

	hitbox = CreateDefaultSubobject<UBoxComponent>(TEXT("Hitbox"));
	hitbox->OnComponentBeginOverlap.AddDynamic(this, &AInteractiveObject::BeginOverlap);

	hitbox->SetRelativeLocation(FVector::ZeroVector);
}

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

	hitbox->SetRelativeLocation(FVector::ZeroVector);

	epressed = false;
	withinrange = false;
}

// Called every frame
void AInteractiveObject::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	if (nightguard->IsValidLowLevel())
	{
		epressed = nightguard->InteractingCPP;
	}
	if (withinrange && epressed)
	{
		OnInteract();
	}
}

void AInteractiveObject::OnInteract()
{
	
}

void AInteractiveObject::BeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	//if (typeid(OtherActor) == typeid(nightguard))
	//{
		nightguard = (ARSGameCharacter*) OtherActor;
		withinrange = true;
	//}
}
void AInteractiveObject::EndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	//if (typeid(OtherActor) == typeid(nightguard))
	//{
		withinrange = false;
	//}
}


(I know EndOverlap wouldn’t work)

Header:



// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/Actor.h"
#include "RSGameCharacter.h"
#include "InteractiveObject.generated.h"

UCLASS()
class RSGAME_API AInteractiveObject : public AActor
{
	GENERATED_BODY()

	ARSGameCharacter* nightguard;

public:	
	// Sets default values for this actor's properties
	AInteractiveObject();

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Collision")
	UBoxComponent* hitbox;

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Mesh)
	USkeletalMeshComponent* meshcomp;

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	virtual void OnInteract();

	UFUNCTION()
	void BeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResultr);
	
	UFUNCTION()
	void EndOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResultr);

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Interactivity")
	bool withinrange;

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Interactivity")
	bool epressed;
	
};