TakeDamage() requires giving FPointDamageEvent and FPointDamageEvent requires giving FHitResult, but OnOverlapBegin() doesn’t generates one. So how am I supposed to Use TakeDamage() with OnOverlapBegin()?
When using On Component Begin Overlap instead, with a collision component, you are returned the following:
Maybe you can use a collision component instead of the On Overlap Begin of the actor itself to get the data you need?
@Antoniusz2115 here you have a working implementation in c++
in header
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AIConfig, meta = (AllowPrivateAccess = "true"))
TSubclassOf<UDamageType> DmgeEvent;
in cpp (ofc bind your overlap with profile name and generate overlap events = true)
// don't forget to include #include "Kismet/GameplayStatics.h" in cpp
void YOURCHARACTER::BeginOverlap(UPrimitiveComponent* HitComp, AActor* HitActor, UPrimitiveComponent* otherActorComp, int32 otherBodyIndex, bool bFromSweep, const FHitResult& SweepResults) {
if (DmgeEvent != nullptr) {
UGameplayStatics::ApplyDamage(HitActor, 10, HitActor->GetInstigatorController(), this, DmgeEvent);
}
}
Where 10 is the amount dealt
1 Like