My UE5 program crashed when the interface function was called
there is my code below:
UKismetSystemLibrary::SphereTraceMultiByProfile(GetWorld(), Start, End, radius, "NPC", false, ActorsToIgnore, EDrawDebugTrace::ForDuration, OutHits, true);
int i = 0;
for (FHitResult hit : OutHits)
{
AActor* hitActor = hit.GetActor();
if (hitActor)
{
if (hitActor->Implements<UVos_Interface_trap>()) // this line has some error
{
APawn* player = Cast<APawn>(GetOwner());
IVos_Interface_trap::Execute_Interact_player(hitActor, player);
//FString message = "execute" + FString::FromInt(i);
//UKismetSystemLibrary::PrintString(this, message, true, true, FLinearColor::Red, 5);
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Interact fail"));
}
i += 1;
}
there is the crash report: