Download

How do you print out everything in a multi-line trace array?


bool wat = World->LineTraceMultiByChannel(Hits,PlayerLocation,PlayerRoation.Vector()*Gun->GetMaxRange(),ECollisionChannel::ECC_Visibility,
        FCollisionQueryParams(FName(""), false, this));

    FHitResult x = FHitResult();

     if (wat)
     {
         for (auto result : Hits)
         {
             FString name = result.GetActor()->GetName();
             UE_LOG(LogTemp, Warning, TEXT("%s"), *name);
         }
     }

My code crashes the editor, the line with the error is FString name = result.GetActor()->GetName();
I got no idea what to do from here



bool wat = World->LineTraceMultiByChannel(Hits,PlayerLocation,PlayerRoation.Vector()*Gun->GetMaxRange(),ECollisionChannel::ECC_Visibility, FCollisionQueryParams(FName(""), false, this));
FHitResult x = FHitResult();
if (wat)
{
for (auto result : Hits)
  {
    if (AActor* HitActor = result.GetActor()) // Verify you have a valid Actor hit (could be a component or some sort).
    {
       FString name = HitActor->GetName();
       UE_LOG(LogTemp, Warning, TEXT("%s"), *name);
    }
  }
}


Thanks! The hits array only has a length of 1 no matter how many objects are traced through(everything is overlap), can you guys help?