Overlapping issues

My issue is related to rendering overlapping output. It doesn’t show whether overlap is true or false. I’m aware of the incorrect setup in the overlapping system.

Here is my code:

include “PlayerCharacter.h”
include “Components/BoxComponent.h”
include “Camera/CameraComponent.h”
include “Components/CapsuleComponent.h”
include “Engine.h”

// Sets default values
APlayerCharacter::APlayerCharacter()
{

  • PrimaryActorTick.bCanEverTick = true;*

  • // Create collision box and set its properties *

  • CollisionBox = CreateDefaultSubobject(TEXT(“CollisionBox”));*

  • CollisionBox->SetCollisionProfileName(TEXT(“Trigger”));*

  • CollisionBox->OnComponentBeginOverlap.AddDynamic(this, &APlayerCharacter::OnOverlapBegin);*

  • CollisionBox->OnComponentEndOverlap.AddDynamic(this, &APlayerCharacter::OnOverlapEnd);*

  • CollisionBox->SetCollisionEnabled(ECollisionEnabled::QueryOnly);*

  • CollisionBox->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);*

  • RootComponent = CollisionBox;*

  • isOverlaping = false;*

  • // Setup camera*

  • FirstPersonCamera = CreateDefaultSubobject(TEXT(“CameraComponent”));*

  • FirstPersonCamera->SetupAttachment(GetCapsuleComponent());*

  • FirstPersonCamera->SetRelativeLocation(FVector(0.0f, 0.0f, 56.0f));*

  • FirstPersonCamera->bUsePawnControlRotation = true;*
    }

// Called when the game starts or when spawned
void APlayerCharacter::BeginPlay()
{

  • Super::BeginPlay();*
    }

// Called every frame
void APlayerCharacter::Tick(float DeltaTime)
{

  • Super::Tick(DeltaTime);*

  • if (GEngine)*

  • {*

  •   GEngine->AddOnScreenDebugMessage(-1, DeltaTime, isOverlaping ? FColor::Green : FColor::Red,*
    
  •   	isOverlaping ? TEXT("isOverlaping is true") : TEXT("isOverlaping is false"));*
    
  •   UE_LOG(LogTemp, Warning, TEXT("Tick function called"));*
    
  • }*
    }

// Called to bind functionality to input
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent PlayerInputComponent)*
{

  • Super::SetupPlayerInputComponent(PlayerInputComponent);*

  • // Movement*

  • PlayerInputComponent->BindAxis(“MoveForward”, this, &APlayerCharacter::MoveForward);*

  • PlayerInputComponent->BindAxis(“MoveRight”, this, &APlayerCharacter::MoveRight);*

  • // Camera*

  • PlayerInputComponent->BindAxis(“Turn”, this, &APlayerCharacter::AddControllerYawInput);*

  • PlayerInputComponent->BindAxis(“LookUp”, this, &APlayerCharacter::AddControllerPitchInput);*
    }

// Overlap functions
void APlayerCharacter::OnOverlapBegin(class UPrimitiveComponent OverlappedComp, class AActor* OtherActor,*

  • class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)*
    {
  • if (OtherActor && (OtherActor != this) && OtherComp)*
  • {*
  •   isOverlaping = true;*
    
  •   if (GEngine)*
    
  •   {*
    
  •   	UE_LOG(LogTemp, Warning, TEXT("Overlap Started"));*
    
  •   	UE_LOG(LogTemp, Warning, TEXT("isOverlaping is true"));*
    
  •   }*
    
  • }*
    }

void APlayerCharacter::OnOverlapEnd(class UPrimitiveComponent OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)*
{

  • if (OtherActor && (OtherActor != this) && OtherComp)*
  • {*
  •   isOverlaping = false;*
    
  •   if (GEngine)*
    
  •   {*
    
  •   	UE_LOG(LogTemp, Warning, TEXT("Overlap Ended"));*
    
  •   	UE_LOG(LogTemp, Warning, TEXT("isOverlaping is false"));*
    
  •   }*
    
  • }*
    }

// Movement functions
void APlayerCharacter::MoveForward(float value)
{

  • AddMovementInput(GetActorForwardVector(), value);*
    }

void APlayerCharacter::MoveRight(float value)
{

  • AddMovementInput(GetActorRightVector(), value);*
    }