Download

linecast and returning a hit for Instance Static Mesh Component

I have a blueprint that has a Instance static mesh component and on that component i go to instances and add a few in the Array. Is it possible to do a linecast and get the hit results of those
instances within the Array. Right now it will return the Instance Static Mesh component but not the instances.

You cannot get separate hit results for the instances as they are the same component but you can discern which instance was hit. The hit result has an int property called Item which will give you the index of the instance. E.g. if the line trace hit the first cube it will be 0, if it hit the second cube it will be 1.

^ this. The instance is not a separate component, but only a set of polygons of the same mesh, so you need to look for specific ids of these sets. You can use the box/sphere overlap function of the component itself to find the instances in location you want.

if (Hit.bBlockingHit)
{
GLog->Log(Hit.GetComponent()->GetName() + Hit.GetActor()->GetName().FromInt(Hit.Item));
//GLog->Log(Hit.GetActor()->GetName() );
//GLog->Log(Hit.GetActor()->GetName().FromInt(Hit.Item));
UE_LOG(LogTemp, Warning, TEXT(“Hit”))
End = Hit.Location;
traceColour = FColor::Blue;
}

I was able to get it done using Hit.Item