Remove instances from the "Begin Overlap" event c++

Hello!

I have 3 instances created from a for in c ++

AMyActor::AMyActor()
{
	PrimaryActorTick.bCanEverTick = true;

	Box = CreateDefaultSubobject<UInstancedStaticMeshComponent>(TEXT("box"));
	Box->SetCollisionProfileName(TEXT("Trigger"));
	Box->bMultiBodyOverlap = true;
	Box->OnComponentBeginOverlap.AddDynamic(this, &AMyActor::BeginOverlap);

	RootComponent = Box;
}

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

	ECP = ()->GetFirstPlayerController()->GetPawn();

	Box->ClearInstances();

	for (size_t i = 0; i < 3; i++)
	{
		Box->AddInstance(FTransform(FVector(i * 180.0f, 0, 0))); 
	}
	
}

252849-captura222.png

from the “BeginOverlap” event I want to delete the specific instance where the event occurs, and keep the other instances.

void AMyActor::BeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{

  OverlappedComponent

}

Look on API reference:

there you can find this:

@anonymous_user_f5a50610

What I want to know is what is the instance where the “BeginOverlap” event is taking place?

For example, I pass my character through the instance and from a log tell me the number of the instance

Excuse my English is bad

@anonymous_user_f5a50610

how to get the instance number? from the “BeginOverlap” function

In your BeginOverlap function SweepResult.Item will contain the number. You can then remove it using Box->RemoveInstance(SweepResult.Item).

thank you very much!

you are a teacher