Getting Actor by actor's name (using hitresult)

// if all conditions in LineTraceSingleByChannel are met.
if (GetWorld()->LineTraceSingleByChannel(*HitResult, StartTrace, EndTrace, ECC_Visibility, *QP))
{
// if hitresults hit the any type of object (hence the != null)
if (HitResult->GetActor() != NULL)
{
// hit results will destroy the following object
HitResult->GetActor()->Destroy();
}
}

hello, i am new to c++ and UE4 and just started this month.

I want to know how to get the actor’s name which is “EditorCube” (3 static mesh actor which are named “EditorCube02”, “EditorCube03”, “EditorCube04”) based on the HitResult.
so that only a specifc static mesh can be destroyed (which is determined by name itself).

Any object that derives from UObjectBaseUtility has a getName() function.

Using that on your HitResult->GetActor() will probably give you what you want.

how to filter them, so that only a part of it can be selected. (i want it to destroy only “editorcube” static mesh only)

AActor const*const actor = HitResult->GetActor();
if (actor && actor->GetName() == “EditorCube”)
{
HitResult->GetActor()->Destroy();
}
Is this what you’re trying to do? Or are you trying to destroy the UStaticMeshComponent associated with the actor named “EditorCube”?

how about if i want to destroy multiple editorcube?