I have a blueprint that’s inheriting from my C++ Class as defined below. Every time I drag the blueprint into the level I get the following crash on ensure(!InSceneComponent->HasAnyFlags(RF_PendingKill));
. My blueprint is just a stock copy of the C++ class with no changes.
Header File
#pragma once
#include "GameFramework/Actor.h"
#include "Components/ArrowComponent.h"
#include "SpringboardActor.generated.h"
UCLASS()
class HYPERSHOOTER_API ASpringboardActor : public AActor
{
GENERATED_UCLASS_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, meta = (ClampMin = "0", ClampMax = "360.0", UIMin = "0", UIMax = "360.0"), Category = "Springboard")
float LaunchDirection;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Springboard")
float LaunchImpulse;
UPROPERTY()
UArrowComponent* MyArrowComponent;
UPROPERTY()
UBoxComponent* MyCollisionBox;
UFUNCTION()
void OnConstruction(const FTransform& myTransform) override;
UFUNCTION()
virtual void ComponentBeginOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
};
Implementation
#include "HyperShooter.h"
#include "HyperShooterCharacter.h"
#include "SpringboardActor.h"
ASpringboardActor::ASpringboardActor(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
MyArrowComponent = ObjectInitializer.CreateDefaultSubobject<UArrowComponent>(this, TEXT("Arrow"));
MyCollisionBox = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("Collision Box"));
MyCollisionBox->OnComponentBeginOverlap.AddDynamic(this, &ASpringboardActor::ComponentBeginOverlap);
}
void ASpringboardActor::ComponentBeginOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
AHyperShooterCharacter* chara = Cast<AHyperShooterCharacter>(OtherActor);
if (chara)
{
chara->GetCharacterMovement()->AddImpulse(MyArrowComponent->GetComponentRotation().Vector() * LaunchImpulse, true);
}
}
void ASpringboardActor::OnConstruction(const FTransform & myTransform)
{
Super::OnConstruction(myTransform);
MyArrowComponent->SetWorldRotation(FRotator(LaunchDirection, 90.f, 0.f));
}