Collision Overlap/debug on screen not working?

Am I missing something? It wont print the message too screen. Right now I’m just trying to see if overlapping with a box with an box component (collider) is working, to then proceed with what I’m trying to do (show a damage counter)

HEADER:

#include "EnemyUITest.generated.h"

UCLASS()
class MAX_API AEnemyUITest : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AEnemyUITest();

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

protected:

	//collider for enemy
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UBoxComponent* EnemyCollider;

	//mesh for enemy
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		UStaticMeshComponent* EnemyMesh;

protected:

	UFUNCTION()
	virtual void OnOverlap(class AActor* OtherActor);

	UFUNCTION(BlueprintImplementableEvent, Category = Damage, meta = (DisplayName = "Apply to Enemy"))
	 void Event_ApplyToEnemy(AMaxCharacter* MaxCharacter);

};

CPP:

#include "Max.h"
#include "EnemyUITest.h"


// Sets default values
AEnemyUITest::AEnemyUITest()
{
 	// 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;

	EnemyCollider = CreateDefaultSubobject<UBoxComponent>(TEXT("Enemy Collider"));
	RootComponent = EnemyCollider;

	EnemyMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Enemy Mesh"));
	EnemyMesh->AttachTo(RootComponent);

}

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

	AMaxCharacter* MaxCharacter = Cast<AMaxCharacter>(*TActorIterator<AMaxCharacter>(GetWorld()));
	
}

// Called every frame
void AEnemyUITest::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}

void AEnemyUITest::OnOverlap(class AActor* OtherActor)
{
	AMaxCharacter* MaxCharacter = Cast<AMaxCharacter>(OtherActor);

	if (MaxCharacter)
	{
		GEngine->AddOnScreenDebugMessage(0, 5.f, FColor::Red, FString::Printf(TEXT("damage counter shows")));
		Event_ApplyToEnemy(MaxCharacter);

		//Destroy();
	}
}

Hey chriis-

In order to call your OnOverlap function you will need to setup a dynamic binding to the overlap function inside your constructor. The following link is to documentation on how exactly to set this up.

Cheers

I knew I was missing something, thanks! It’s now working