I’m testing on two objects that both use the UFO static mesh from the flight starter template. On both Static Meshes I’ve set the Generate Overlap Events, set CollisionPresets to OverlapAll, and set Simulation Generates Hit Events.
In my constructor I have:
static ConstructorHelpers::FObjectFinder P2MeshClass(TEXT("StaticMesh'/Game/Flying/Meshes/UFO.UFO'"));
PlaneMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PlaneMesh0"));
PlaneMesh->SetStaticMesh(P2MeshClass.Object);
Planemesh->OnComponentBeginOverlap.AddDynamic(this, &ASpaceGamePawn::OverlapBegin)
I also have:
PlaneMesh->OnComponentHit.AddDynamic(this, &ASpaceGamePawn::OnHit);
and
this->OnActorBeginOverlap.AddDynamic(this, &ASpaceGamePawn::ActorOverlapBegin);
And later on, here is OverlapBegin
void ASpaceGamePawn::OverlapBegin(class AActor* Other, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& Hit)
{
//Super::NotifyHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit);
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Blue, TEXT("YAAARRRR"));
// Pass to Dynamics Component
UActorComponent* OtherSDCActorComp = Other->FindComponentByClass(USpaceDynamicsComponent::StaticClass());
USpaceDynamicsComponent* OtherSDC = Cast<USpaceDynamicsComponent>(OtherSDCActorComp);
if (!OtherSDC)
return;
SDC->NotifyHit(OtherSDC, Hit.ImpactPoint, Hit.ImpactNormal);
}
NotifyHit does work when the two things are set to BlockAll, and NotifyActorBeginOverlap works when they’re set to overlap all, but why don’t the components work?
Unfortunately NotifyActorBeginOverlap doesn’t work for me since it doesn’t have the HitLocation and HitNormal vectors or an FHitResult.