Hit Trigger
Unreal
APlayerChar::APlayerChar() { OnComponentBeginOverlap.AddDynamic(this, &APlayerChar::OnCompHit); }//if not working the AddDynamic Function delegate use on BeginPlay()
void APlayerChar::OnOverlapBegin(class UPrimitiveComponent* OverlappedComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) { //CurrentJumpCount = 0;
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::Printf(TEXT("I Hit: %s"), *OtherComp->GetName()));
if(OtherComp.ComponentHasTag("theComponent")) UE_LOG(LogTemp, Warning, TEXT("Overlap theComponent"));
}
Unity
[SerializeField] string colliderName;
void OnTriggerEnter(Collider collider) => colliderName = collider.gameObject.name;
Comments
Post a Comment