# How do I override UFUNCTIO() functions

**URL:** <https://forums.unrealengine.com/t/how-do-i-override-ufunctio-functions/448917>\
**Category:** Community & Industry Discussion\
**Tags:** override, inheritance, ufunction, initialization, unreal-engine, question\
**Created:** [May 13, 2019, 7:51pm UTC](https://forums.unrealengine.com/t/how-do-i-override-ufunctio-functions/448917 "2019-05-13T19:51:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![limbusdev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@limbusdev](https://forums.unrealengine.com/u/limbusdev)\
**Post date:** [May 13, 2019, 7:51pm UTC](https://forums.unrealengine.com/t/how-do-i-override-ufunctio-functions/448917/1 "2019-05-13T19:51:49Z")

</div>

Hi there,  
I created a generic `ASimpleTriggerVolume` and another more concrete `ASimpleBoxTriggerVolume` which overrides some functions. Unfortunately Unreal Editor instantly crashes when trying to start it with this implementation:

**SimpleTriggerVolume.h** :

```cpp
UCLASS()
class BEATEMDOWN_API ASimpleTriggerVolume : public AActor
{
	GENERATED_BODY()
	
public:	

	ASimpleTriggerVolume();

protected:

	UPROPERTY(VisibleAnywhere, Category = "Setup")
	UShapeComponent* Shape = nullptr;

	virtual void BeginPlay() override;

public:	

	virtual void Tick(float DeltaTime) override;

protected:

	UFUNCTION()
	virtual void OnTriggerOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

	UFUNCTION()
	virtual void OnTriggerOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);

	UFUNCTION()
	virtual void SetupShapeComponent();

	UFUNCTION()
	virtual void BindTriggerCallbacksToShape();

};

```

and **SimpleTriggerVolume.cpp** :

```cpp
ASimpleTriggerVolume::ASimpleTriggerVolume()
{
	PrimaryActorTick.bCanEverTick = true;

	SetupShapeComponent();
	BindTriggerCallbacksToShape();
}

void ASimpleTriggerVolume::BeginPlay() { Super::BeginPlay(); }

void ASimpleTriggerVolume::Tick(float DeltaTime) { Super::Tick(DeltaTime); }

void ASimpleTriggerVolume::SetupShapeComponent()
{
	auto BoxTrigger = CreateDefaultSubobject<UBoxComponent>(FName("Trigger Shape"));
	BoxTrigger->SetBoxExtent(FVector(50.f, 50.f, 50.f));
	BoxTrigger->SetGenerateOverlapEvents(true);
	Shape = BoxTrigger;
}

void ASimpleTriggerVolume::BindTriggerCallbacksToShape()
{
	if (Shape)
	{
		Shape->OnComponentBeginOverlap.AddDynamic(this, &ASimpleTriggerVolume::OnTriggerOverlapBegin);
		Shape->OnComponentEndOverlap.AddDynamic(this, &ASimpleTriggerVolume::OnTriggerOverlapEnd);
	}
}

void ASimpleTriggerVolume::OnTriggerOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	UE_LOG(LogTemp, Warning, TEXT("SimpleTriggerVolume::OnTriggerOverlapBegin()"));
}

void ASimpleTriggerVolume::OnTriggerOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
	UE_LOG(LogTemp, Warning, TEXT("SimpleTriggerVolume::OnTriggerOverlapEnd()"));
}

```

With only this script, everyhing works fine. As soon as I inherit from it and override the UFUNCTION **SetupShapeComponent** Unreal crashes, even before I can hit play.

**SimpleBoxTriggerVolume.h** :

```cpp
UCLASS()
class BEATEMDOWN_API ASimpleBoxTriggerVolume : public ASimpleTriggerVolume
{
	GENERATED_BODY()

public:	

	UPROPERTY(EditAnywhere, Category = "Geometry")
	FVector TriggerExtent = FVector(50.f, 50.f, 50.f);

	ASimpleBoxTriggerVolume();

	virtual void BeginPlay() override;

	virtual void Tick(float DeltaTime) override;

protected:
///////////////////////////////////////////////////////////////////////////////
//// ASimpleTriggerVolume

	virtual void SetupShapeComponent() override;
};

```

and **SimpleBoxTriggerVolume.cpp** :

```cpp
ASimpleBoxTriggerVolume::ASimpleBoxTriggerVolume()
{
	PrimaryActorTick.bCanEverTick = true;

	RootComponent = CreateDefaultSubobject<USceneComponent>(FName("Root Component"));

        SetupShapeComponent();
	BindTriggerCallbacksToShape();

}

void ASimpleBoxTriggerVolume::BeginPlay(){Super::BeginPlay();}

void ASimpleBoxTriggerVolume::Tick(float DeltaTime){Super::Tick(DeltaTime);}

void ASimpleBoxTriggerVolume::SetupShapeComponent()
{
	auto BoxTrigger = CreateDefaultSubobject<UBoxComponent>(FName("Trigger Shape"));
	BoxTrigger->SetBoxExtent(TriggerExtent);
	BoxTrigger->SetGenerateOverlapEvents(true);
	Shape = BoxTrigger;
}

```
