// 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).
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”?