I’ve set up a simple event that is supposed to trigger when my powerup crate detects a hit on something.
About 50% of the time however, I hit a breakpoint when hitting PIE or Simulate in the engine code, yet I’m sure I have everything set-up properly? (Could do with more documentation on this btw!)
BZGame_PowerUp.H:
/* Called When The Powerup Collision Overlaps With Something */
UFUNCTION(BlueprintNativeEvent)
void OnCollectHit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
BZGame_PowerUp.cpp:
Constructor:
GetCrateMesh()->OnComponentHit.AddDynamic(this, &ABZGame_PowerUp::OnCollectOverlap);
void ABZGame_PowerUp::OnCollectOverlap_Implementation(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::Printf(TEXT("Test")));
APawn* Collector = Cast<APawn>(OtherActor);
if (Collector)
{
//if (CanPawnCollect(Collector))
//{
// CollectPowerUp(GetGameObjectFromOverlap(Collector));
//}
//else
//{
// RejectPowerUp();
//}
}
}