OnComponentBeginOverlap function is not being called

I’m trying to call a custom method when an overlap occurs. I have a sphere, and a box. The sphere moves around on its own with constant velocity bouncing off walls. The box is controlled by the player along one axis. When the ball hits the box I want it to flip its y velocity.

Based on answers I read here I initialize my ball with,

Aball::Aball()
{
 	// 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;
	SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("ROOT"));
	RootComponent = SphereComponent;
	VisibleComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VISIBLE"));
	VisibleComponent->AttachTo(RootComponent);
	SphereComponent->OnComponentBeginOverlap.AddDynamic(this, &Aball::Paddle_Hit);

}

And Paddle_Hit looks like,

void Aball::Paddle_Hit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	Velocity.Y = Velocity.Y*-1.0f;
}

With the following line for it in the header as well,

void Paddle_Hit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

I also set up both objects to accept overlap,

I also set the movement updates to use the proper SetActorLocation I found here. For the sphere,

void Aball::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	FVector location = GetActorLocation();
	if (location.X >= 240.0f || location.X <= -240.0f)
		Velocity.X = Velocity.X*-1.0f;
	SetActorLocation(location + Velocity*DeltaTime*100.0f, true);
}

For the box,

void Apaddle::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	if (!CurrentDirection.IsZero())
	{
		FVector location = GetActorLocation();
		if ((location.X >= 200.0f && CurrentDirection.X<0.0f) || (location.X <= -200.0f && CurrentDirection.X>0.0f) || (location.X < 200.0f && location.X > -200.0f))
			SetActorLocation(location + CurrentDirection*DeltaTime,true);
	}
}

The problem is that when the box and sphere collide in game, nothing seems to happen. Am I missing something obvious?

I am having the exact same problem!

I’m not 100% sure on this, but I think you are probably looking for the OnHit Function, which can be defined like so:

Object->OnComponentHit.AddDynamic(this, &AMyClass::OnHit);

OnOverlap is normally used for triggerboxes, checking if the triggerbox is overlapping the player. Onhit is used to check if the component hits something blocking

I made the suggested changes to my code and it didn’t seem to change anything. I even changed the code in Paddle_Hit to Destroy() so that it would be more visible if something happened.

I replaced my old OnComponentBeginOverlap with

	SphereComponent->OnComponentHit.AddDynamic(this, &Aball::Paddle_Hit);

The header/function parameters were also changed.
I change the objects to sent hit messages,

http://i.imgur.com/XrIGtBI.png

Since I changed everything to block the sphere stops when it hits the box at least,

http://i.imgur.com/zrwzMfl.png

I managed to get it to work by removing the OnComponentHit/OnComponentBeginOverlap and instead overriding the virtual function NotifyHit,

    void Aball::NotifyHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
{ //stuff}

It is also necessary to add it to the header,

virtual void NotifyHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit);

This gets properly called my sphere hits the box.

i have the same problem with OnComponentBeginOverlap, somebody pls help